Log in with Pinterest

后端 未结 3 2056
离开以前
离开以前 2021-01-19 15:40

I can easy implement log in with facebook on iPhone. But I heared, that there was no official API for pinterest.

So I wonder if there is a way to implement login wi

3条回答
  •  孤城傲影
    2021-01-19 15:51

    Hi there is no official api for Pinterest, But
    Here is a link already answered

    or try like this, create button with the following target
    [pintrestBtn addTarget:self action:@selector(pintrestButtonSelcted) forControlEvents:UIControlEventTouchUpInside]

    and push when the htmlstring comes as perfect url push it to another viewcontroller which has webview and load this htmlstring in that 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:@" "];
    [htmlString appendFormat:@"

    ", buttonUrl]; [htmlString appendFormat:@"

    ", imageUrl]; [htmlString appendFormat:@""]; [htmlString appendFormat:@" "]; return htmlString;

    }

提交回复
热议问题