使用Pinterest登录

时间:2012-12-05 05:51:35

标签: iphone objective-c ios login pinterest

我可以轻松实现在iPhone上登录facebook。但我听说,没有正式的API用于解决问题。

所以我想知道是否有办法用Pinterest实现登录。所以我的应用程序可以在用户登录后识别用户。

3 个答案:

答案 0 :(得分:4)

Without an official Pinterest public API,你写的任何其他任何解决方法都可能很容易破解。最好直接向Pintrist注册,希望他们一旦获得它就能让您获得访问beta SDK或API的权利。

那就是there appears to be some stuff potentially available,但不确定目前的状态是什么。

答案 1 :(得分:1)

Pintrest使用oAuth2你应该能够使用它类似于所有其他提供者,即GET请求到某个url获取令牌,可以在这里找到一步一步的说明 http://tijn.bo.lt/pinterest-api

OAuth2是官方API,问题归结为找到端点和GET语法 需要注意的一点是,返回的对象可以包含不同的提供者值,例如我需要Twitter和FB解决方案,但Twitter不会为您提供用户的电子邮件,因此您必须单独请求它(以便唯一地标识它)帐户包括提供商) 对于ruby,omniauth gem可以让您轻松使用多个提供程序(策略)。不应该复杂地推出自己的解决方案或为IOS找到一个库

答案 2 :(得分:0)

嗨,Pinterest没有官方api,但是Here已经回复了链接

或尝试这样,创建具有以下目标的按钮
[pintrestBtn addTarget:self action:@selector(pintrestButtonSelcted) forControlEvents:UIControlEventTouchUpInside]

并在htmlstring完美推送时将其推送到另一个具有webview并在该webview中加载此htmlstring的viewcontroller

- (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;

}