iPhoneのFacebookでログインを簡単に実装できます。しかし、Pinterestの公式APIはないと聞いた。
だから、Pinterestでログインを実装する方法があるのだろうか。そのため、私のアプリは、pinterestでログインした後にユーザーを識別できます。
iPhoneのFacebookでログインを簡単に実装できます。しかし、Pinterestの公式APIはないと聞いた。
だから、Pinterestでログインを実装する方法があるのだろうか。そのため、私のアプリは、pinterestでログインした後にユーザーを識別できます。
Pintrest は oAuth2 を使用します。他のすべてのプロバイダーと同様に使用できるはずです。つまり、トークンを取得するために特定の URL への GET 要求を使用できます。詳細な手順については、http://tijn.bo.lt/pinterest-api を参照してください 。
OAuth2 は公式の API であり、問題はエンドポイントと GET 構文を見つけることに要約されます 注意すべきことの 1 つは、返されるオブジェクトにプロバイダ間で異なる値が含まれる可能性があることです。たとえば、Twitter と FB のソリューションが必要でしたが、Twitter では提供されませんルビーには、複数のプロバイダー (戦略) を簡単に使用できる omniauth gem があります。独自のソリューションを展開したり、IOS 用のライブラリを見つけたりするのはそれほど複雑ではありません。
こんにちは、Pinterest の公式 API はありません が、既に回答済みのリンクがあり
ます
または、このようにして、次のターゲットでボタンを作成します
[pintrestBtn addTarget:self action:@selector(pintrestButtonSelcted) forControlEvents:UIControlEventTouchUpInside]
htmlstring
完璧なURLが来たらプッシュし、 webviewを持つ別のviewcontrollerにプッシュしhtmlstring
、そのwebviewにロードします
- (void) pintrestButtonSelcted {
NSString *htmlString = [self generatePinterestHTMLForSKU:nil];
NSLog(@"Generated HTML String:%@", htmlString);
WebViewController *webViewController = [[WebViewController alloc] init];
webViewController.htmlString = htmlString;
webViewController.view.frame = CGRectMake(0, 0, 300, 300);
[self presentModalViewController:webViewController animated:YES];
}
- (NSString*) generatePinterestHTMLForSKU:(NSString*)sku {
NSString *description = @"Post your description here";
// Generate urls for button and image
NSString *sUrl = [NSString stringWithFormat:@"http://reedperry.com/2011/04/27/apple-logo/"];
NSLog(@"URL:%@", sUrl);
NSString *protectedUrl = ( NSString *)CFURLCreateStringByAddingPercentEscapes(NULL,( CFStringRef)sUrl, NULL, (CFStringRef)@"!*'\"();:@&=+$,/?%#[]% ",CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding));
NSLog(@"Protected URL:%@", protectedUrl);
NSString *imageUrl = [NSString stringWithFormat:@"\"%@\"", sUrl];
NSString *buttonUrl = [NSString stringWithFormat:@"\"http://pinterest.com/pin/create/button/?url=http://itunes.apple.com/us/app/pinterest/id429047995?mt=8&media=http://reedperry.com/2011/04/27/apple-logo/%@&description=Welcome you all%@\"", protectedUrl, description];
NSMutableString *htmlString = [[NSMutableString alloc] initWithCapacity:1000];
[htmlString appendFormat:@"<html> <body>"];
[htmlString appendFormat:@"<p align=\"center\"><a href=%@ class=\"pin-it-button\" count-layout=\"horizontal\"><img border=\"0\" src=\"http://assets.pinterest.com/images/PinExt.png\" title=\"Pin It\" /></a></p>", buttonUrl];
[htmlString appendFormat:@"<p align=\"center\"><img width=\"400px\" height = \"400px\" src=%@></img></p>", imageUrl];
[htmlString appendFormat:@"<script type=\"text/javascript\" src=\"//assets.pinterest.com/js/pinit.js\"></script>"];
[htmlString appendFormat:@"</body> </html>"];
return htmlString;
}