Thursday, 15 May 2014

iphone - Pinterest integration in ios app? -



iphone - Pinterest integration in ios app? -

i trying post image app on pinterest.from lastly 5 days looking perfect solution after posting question on inch away solve problem.the issue when post image using url successfuly post image on pinterest below code show.

-(nsstring*) generatepinteresthtml { nsstring *description = @"post description here"; nsstring *surl = [nsstring stringwithformat:@"http://4.bp.blogspot.com/-w4otzjlpgwo/t5_pi-kjpui/aaaaaaaaaom/rkm3e0xcbgy/s1600/flower.png"]; nslog(@"url:%@", surl); nsstring *protectedurl = (__bridge nsstring *)cfurlcreatestringbyaddingpercentescapes(null,(__bridge 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=www.flor.com&media=%@&description=%@\"", 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>"]; homecoming htmlstring; } -(void)viewdidload { [super viewdidload]; nsstring *htmlstring = [self generatepinteresthtml]; nslog(@"generated html string:%@", htmlstring); mywebview.backgroundcolor = [uicolor clearcolor]; mywebview.opaque = no; if ([mywebview ishidden]) { [mywebview sethidden:no]; } [mywebview loadhtmlstring:htmlstring baseurl:nil]; }

below screen shot show above code result

but when trying upload image app not works fine here code

- (void)viewdidload { nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory,nsuserdomainmask, yes); nsstring *documentsdirectory = [paths objectatindex:0]; savedimagepath = [[documentsdirectory stringbyappendingpathcomponent:@"savedimage.png"] mutablecopy]; nslog(@"savedimagepath..%@",savedimagepath); nsdata* imagedata = uiimagepngrepresentation(mypimage); [imagedata writetofile:savedimagepath atomically:yes]; [super viewdidload]; nsstring *htmlstring = [self generatepinteresthtml]; nslog(@"generated html string:%@", htmlstring); mywebview.backgroundcolor = [uicolor clearcolor]; mywebview.opaque = no; if ([mywebview ishidden]) { [mywebview sethidden:no]; } [mywebview loadhtmlstring:htmlstring baseurl:nil]; } - (nsstring*) generatepinteresthtml { nsstring *description = @"post description here"; nsstring *stringurl = [nsstring stringwithformat:@"%@",savedimagepath]; nslog(@"stringurl:%@", stringurl); nsurl *urltoupload = [[nsurl alloc]initfileurlwithpath:stringurl]; nsstring* surl = [nsstring stringwithformat:@"%@",urltoupload]; nsstring *protectedurl = (__bridge nsstring *)cfurlcreatestringbyaddingpercentescapes(null,(__bridge 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=www.flor.com&media=%@&description=%@\"", 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>"]; homecoming htmlstring; }

for above code screen shot result link1link2 please suggest method reslove problem.thanks

after posted images on server , assigned appropriate url address pinit button, worked me. post answers herefor post local images app on pinterest.

hope helpful all.

thanks

iphone ios xcode webview pinterest

No comments:

Post a Comment