Hi, there is no official api for Pinterest, but
Here is already a reciprocal link
or try to do this, create a button with the following purpose
[pintrestBtn addTarget:self action:@selector(pintrestButtonSelcted) forControlEvents:UIControlEventTouchUpInside]
and click when htmlstring becomes the perfect url, click it in another view manager which has a htmlstring and loads that htmlstring into this htmlstring
- (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;
}
source share