iOS application integration with pinterest [closed] - iphone

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
What is the most reliable way currently to allow pinterest sharing from iOS app?
Pinterest API is not public yet and only suggested way to share is their web button.

I made a pinterest integration in my iPad app. But, because Pinterest doesn't have an API for posting yet, I used the following method. I just create programmatically an HTML Web Page and add a Pin it button to that page programmatically. Then I show a Web View and allow user to click Pin it once more. These are more explained steps.
1) Create a WebViewController, that has a UIWebView. Add Close button, add UIWebViewDelegateProtocol, spinner, htmlString property.
2) Generate an HTML programmatically to put to that UIWebView, when user clicks your "Pin it" button in your app. In this case I put to the HTML page different images for different products.
- (NSString*) generatePinterestHTMLForSKU:(NSString*)sku {
NSString *description = #"Post your description here";
// Generate urls for button and image
NSString *sUrl = [NSString stringWithFormat:#"http://d30t6wl9ttrlhf.cloudfront.net/media/catalog/product/Heros/%#-1.jpg", sku];
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\"><img border=\"0\" src=\"http://assets.pinterest.com/images/PinExt.png\" title=\"Pin It\" /></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;
}
This is an example of my HTML page generation method.
3) Create a method to call when user taps your "Pin it" button, which shows that webView with the image, that you will post and the "Pin it" button on the UIWebView. This is my example:
- (void) postToPinterest {
NSString *htmlString = [self generatePinterestHTMLForSKU:self.flProduct.sku];
NSLog(#"Generated HTML String:%#", htmlString);
WebViewController *webViewController = [[WebViewController alloc] initWithNibName:#"WebViewController" bundle:nil];
webViewController.htmlString = htmlString;
webViewController.showSpinner = YES;
[[[[UIApplication sharedApplication] keyWindow] rootViewController] presentModalViewController:webViewController animated:YES];
}
4) Put a "Close" button to your WebViewController to close it. Also you can add spinners to track the loading of the UIWebView.
- (IBAction)closeClicked:(id)sender {
[self dismissModalViewControllerAnimated:YES];
}
- (void)webViewDidStartLoad:(UIWebView *)webView {
if (showSpinner) {
// If we want to show Spinner, we show it everyTime
[UIHelper startShowingSpinner:self.webView];
}
else {
// If we don't -> we show it only once (some sites annoy with it)
if (!spinnerWasShown) {
[UIHelper startShowingSpinner:self.webView];
spinnerWasShown = YES;
}
}
}
-(void)webViewDidFinishLoad:(UIWebView *)webView {
[UIHelper stopShowingSpinner];
}
P.S. I used the same method to add Google Plus's +1 button to the iPad app. (It doesn't have posting API too, only readonly API at the moment)

If you only want to share(i.e. pin on a user board), then you can use iphone-URL-Scheme and call the Pinterest application along with the parameters url(URL of the page to pin), media(URL of the image to pin) & description(Description of the page to be pinned). Present a UIAlertView and forward them to appstore to download the official Pinterest application if the user has not installed it.
Reference:
http://wiki.akosma.com/IPhone_URL_Schemes#Pinterest
Code to open Pinterest Applicaiton:
NSURL *url = [NSURL URLWithString:#"pinit12://pinterest.com/pin/create/bookmarklet/?url=URL-OF-THE-PAGE-TO-PIN&media=URL-OF-THE-IMAGE-TO-PIN&description=ENTER-YOUR-DESCRIPTION-FOR-THE-PIN"];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
}else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Pinterest" message:#"Would you like to download Pinterest Application to share?" delegate:self cancelButtonTitle:#"Cancel" otherButtonTitles:#"Continue", nil];
[alert show];
}
UIAlertViewDelegate Method
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 1){
NSString *stringURL = #"http://itunes.apple.com/us/app/pinterest/id429047995?mt=8";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];
}
}

As of May 20th 2013, Pinterest have released an iOS SDK for pinning content.
Check out their Developers site for more information.

I've looked high and low too. I've even contacted Pinterest Team about an SDK. The closest thing I have found is a PHP wrapper on github https://github.com/kellan/pinterest.api.php.
It's not the best solution though because it is unofficial api and will most likely break.

I tried to integrate Pinterest with Custom URL Scheme, also download the Pinterest application on my device, but not abel to integrate with it.
And the thing is that i don't want to used webView for integration so is it possible to do that, i didn't found any application on app store which have pinterest integration.
I did googling also but all worse, Snapguide also remove pinterest integration from their application.
I used a webView code to pin image , no need to open full Pinterest website,
NSString *urlStr =[NSString stringWithFormat:#"http://pinterest.com/pin/create/bookmarklet/?url=www.<domainname>.com&media=http://<domainname>.files.com/hello.jpg?w=495&description=hello"];
This would be easy but with webView and that i don't want.

Related

How to get Google Plus login information from GTMOAuth2Authentication and GTMOAuth2ViewControllerTouch and set user as logIn in UIWebView

In my iphone application, I am using Google Plus SDK to sign in for my login page of app to allow user to login with google plus.But when user is in another View Controller and when user is pressed button(Called Add on Google Plus) then i am opening UIWebView for searching people on google plus as below:
NSString *url_string =[NSString stringWithFormat:#"https://plus.google.com/u/0/s/%#/people",self.selectedMatch.realName];
NSString *urlEscaped = [url_string stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
UIViewController *webViewController = [[UIViewController alloc]init];
UIWebView *webView = [[UIWebView alloc]initWithFrame:CGRectMake(0,0,320,480)];
webView.scalesPageToFit= YES;
NSURL *nsurl = [NSURL URLWithString:urlEscaped];
NSURLRequest *nsrequest = [NSURLRequest requestWithURL:nsurl];
[webView loadRequest:nsrequest];
[webViewController.view addSubview:webView];
[self.navigationController pushViewController:webViewController animated:YES];
But when this webView is opened then user is no longer logged in.Web view is asking again to sign in to user.Any one know how to Logged in user in UIWebView. Any help will be appreciated.

Log in with Pinterest

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 with Pinterest. So my app can identify user after his login with pinterest.
Without an official Pinterest public API, anything else you write to be some kind of workaround is likely to break very easily. Best to register with Pintrist directly and hopefully they'll seed you with access to a beta SDK or API, once they come up with it.
That said, there appears to be some stuff potentially available but not sure what the current status is.
Pintrest uses oAuth2 you should be able to use it akin of all the other providers ie GET request to a certain url to obtain the token, step by step instructions can be found here
http://tijn.bo.lt/pinterest-api
OAuth2 is an official api the issue boils down to finding the endpoint and GET syntax
One thing to note is the object that is being returned can contain different values accross providers for instance I needed a Twitter and FB solution, but Twitter doesn't give you user's email so you had to ask for it separately (to uniquely identify the same account accross providers)
For ruby there's the omniauth gem that lets you use multiple providers (strategies) with ease. Shouldn't be to complicated to roll out your own solution for or find a library for IOS
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:#"<html> <body>"];
[htmlString appendFormat:#"<p align=\"center\"><img border=\"0\" src=\"http://assets.pinterest.com/images/PinExt.png\" title=\"Pin It\" /></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;
}

Best way to have article text with links on iPhone?

I am making an iPhone app that has a bunch of "articles" with certain words that I want to link to other "articles". I need to display the articles in UITableViewCells.
If there is a way to do this without a web view, that's great.
If I need to use a web view, should I just make <a href> style links? How can I have it jump to the article without creating a bunch of actual html pages, just have it let my program know that they clicked on that link and then the program goes and finds the appropriate article from a plist or something?
I've create a test demo using UIWebView and it works fine.
Create two HTML files:home.html and first.html.
// home.html
Home page. first
// first.html
First page. home
//viewDidLoad
self.webView.delegate = self;
NSString *htmlFilePathString = [[NSBundle mainBundle] pathForResource:#"home" ofType:#"html"];
NSURL *htmlFileURL = [[NSURL alloc] initFileURLWithPath:htmlFilePathString];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:htmlFileURL];
[self.webView loadRequest:request];
// webView's delegate:
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
return YES;
}

How to post an images on Google Plus in an iOS Application

I successfully posted content and (Links)URL using Google Plus API in iphone.
Using Following code:
googleShare =[[[GooglePlusShare alloc] initWithClientID:#"my key"] autorelease];
[googleShare setDelegate:self];
appDelegate.shareGOOGLe =googleShare;
NSString *inputURL = #"";
NSURL *urlToShare = [inputURL length] ? [NSURL URLWithString:inputURL] : nil;
NSLog(#"%#",urlToShare);
NSString *inputText = #"TEst Sharing testing from iOS 5.0";
NSString *text = [inputText length] ? inputText : nil;
NSLog(#"%#",text);
[[[[googleShare shareDialog]
setURLToShare:urlToShare]
setPrefillText:shareMessge] open];
But I want to post images to google plus.
Can any one help me?
Thanks in advance.
It is currently not possible to share images on Google+ with the Google+ iOS SDK.
This is possible to share a Image with google plus
- (IBAction) didTapShare: (id)sender {
id<GPPNativeShareBuilder> shareBuilder = [[GPPShare sharedInstance] nativeShareDialog];
[shareBuilder attachImage:[UIImage imageNamed:#"yourImagename.png"]];
[shareBuilder open];
}
Referenced from https://developers.google.com/+/mobile/ios/share/
#Chirag... You should see Flipboard application for iPhone/iPad. It shares the link,comment and Image on Google+ account. Please take a look and let me know if i am wrong at any point.
These are the links will help:
Link Shows how and what can be shared.
https://developers.google.com/+/mobile/ios/share/
at the bottome of link 1, it mentions "Attaching media to your shared posts. You can attach pictures and movies to your posts for your users to share to their stream."
https://developers.google.com/+/mobile/ios/share/media
Link 2 shows the code snippet to share the media ; images and videos
Following is the Code snippet to share Image on google+
- (IBAction) didTapShare: (id)sender {
id<GPPNativeShareBuilder> shareBuilder = [[GPPShare sharedInstance] nativeShareDialog];
// Set any prefilled text that you might want to suggest
[shareBuilder setPrefillText:#"Achievement unlocked! I just scored 99 points. Can you beat me?"]
NSString *fileName = #"samplemedia1";
[shareBuilder attachImage:[UIImage imageNamed:fileName];
[shareBuilder open];
}

adding photo on facebook wall

- (void)postToWall {
FBStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.userMessagePrompt = [NSString stringWithFormat: subjectTitle]; //subjectTitle works here but not as name where i need it.
NSString *src = #"http://www.sample.com/image.png";
NSString *name = storyLink; //<---------------------------------works with storyLink but not subjectTitle. I need subjectTitle to work here
NSString *href = storyLink;
NSString *attachment = [NSString stringWithFormat:#"{\"name\":\"%#\",\"media\":[{\"type\":\"image\", \"src\":\"%#\", \"href\":\"%#\"}]}", name, src, href];
dialog.attachment = attachment;
[dialog show];
}
i want to add image from photo library instred of http://www.sample.com/image.png to the facebook wall.
can anyone provides me help ....
Thanks in advance ......
You can access the URL's of the iPhoto library items using the UIImagePickerController and its delegate method.
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
When the user picks a photo the URL will be in the dictionary under the key UIImagePickerControllerMediaURL
Probably this Stack Overflow Question about uploading images to Facebook might help you.
Also Sharekit is a nice framework to add Social features to you iPhone App. I think it has facility to share images. You can check it out at Sharekit official website.