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

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];
}

Related

How to post video on twitter in iPhone sdk

I am an ios developer,i am working on app in which i needs to send video on twitter.But i searched and found that we can only post link of Video,but cannot post the video itself in iPhone sdk.
Can anyone suggest me what to do,if i need to post video on twitter.
You can use TWRequest class with
- (void)addMultiPartData:(NSData *)data withName:(NSString *)name type:(NSString *)type
I am not sure if uploading video is possible.
More on using TWRequest https://dev.twitter.com/docs/ios/posting-images-using-twrequest
I just suggest you to look over the TwitVid documentation From bellow link:
http://twitvid.pbworks.com/w/page/22556295/FrontPage
UPDATE:
i use this type of logic in 4.3 with shareKit
NSString *urlstr =[YorURL stringByReplacingOccurrencesOfString:#" " withString:#""];
[urlstr retain];
NSString *apiEndpoint = [NSString stringWithFormat:#"http://tinyurl.com/api-create.php?url=%#",urlstr];
[apiEndpoint retain];
NSLog(#"\n\n APIEndPoint : %#",apiEndpoint);
NSString *shortURL = [NSString stringWithContentsOfURL:[NSURL URLWithString:apiEndpoint]
encoding:NSASCIIStringEncoding
error:nil];
[shortURL retain];
NSLog(#"Long: %# - Short: %#",urlstr,shortURL);
NSString *txtShare=[NSString stringWithFormat:#"You watching Your %#",shortURL];
SHKItem *item = [SHKItem text:txtShare];
[SHK setRootViewController:self];
[SHKTwitter shareItem:item];
hope this help you...
Thanks to the uploading media new API, you can share video to twitter. And I have tried it, it works.
Please check this: https://github.com/liu044100/SocialVideoHelper
You just need to call this class method.
+(void)uploadTwitterVideo:(NSData*)videoData account:(ACAccount*)account withCompletion:(dispatch_block_t)completion;
Hope it can resolve your problem.

Get Facebook profile pic using 3.0 SDK

I'm having trouble getting the user's profile pic with the new Facebook SDK. All the answers on here use methods from the old SDK that no longer work.
I've tried using the FBProfilePictureView recommended in Facebook's tutorial, but this picture doesn't get cached and I don't think it can be converted into a UIImage.
Can anyone please provide some help? Thanks!
OK, I finally got this using the following:
imageData = [[NSMutableData alloc] init]; // the image will be loaded in here
NSString *urlString = [NSString stringWithFormat:#"http://graph.facebook.com/%#/picture?type=large", user.id];
NSMutableURLRequest *urlRequest =
[NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:2];
// Run request asynchronously
NSURLConnection *urlConnection = [[NSURLConnection alloc] initWithRequest:urlRequest
delegate:self];
if (!urlConnection)
NSLog(#"Failed to download picture");
Then I used -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data and -(void)connectionDidFinishLoading:(NSURLConnection *)connection to put the image together.
Best solution i've found:
I've used UIImage from AFNetworking https://github.com/AFNetworking/AFNetworking. It handles redirect and caching so you can fetch profile picture for every user id you have.
NSString *imageUrl = [NSString stringWithFormat:#"http://graph.facebook.com/%#/picture", ((NSDictionary<FBGraphUser> *) [self.friends objectAtIndex: indexPath.row]).id];
[friendCell.imageView setImageWithURL:[NSURL URLWithString:imageUrl] placeholderImage:[UIImage imageNamed:#"profile.jpg"]];
Use https://github.com/rs/SDWebImage to cache the image. The URL to request the image should be
NSString *string = [NSString stringWithFormat:#"https://graph.facebook.com/%#?fields=picture", userid];
Use the link:
https://graph.facebook.com/me?fields=picture
to get the current user's profile picture.
Facebook provides the Graph API explorer tool which can come in handy when you want to try queries or to check the returned output.
Here's a link to the User API Reference.
If your problem is related to "self.userPofilePicture.profileID = user.id;".
Then self.userProfilePicture return UIView so just take View and display in it.
Don't forgot add class FBProfilePictureView in Identity Inspector as well as [FBProfilePictureView class] to AppDelegate implementation file.
I hope this will helpful.

iOS application integration with pinterest [closed]

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.

How to get a link of the video I uploaded to YouTube

My code can upload the video to YouTube successfully, I want to get the embed link of the uploaded video, and put this link to another website, so that I can see the video from that website.
How can I get that link?
I use code below to upload the video, but I can not see any useful information from the returned ticket.
GDataServiceTicket *ticket;
ticket = [service fetchEntryByInsertingEntry:entry
forFeedURL:url
delegate:self
didFinishSelector:#selector(uploadTicket:finishedWithEntry:error];
Is there anyone can help me out here?
Thanks a lot
You should be able to get the url from the entry object in your callback handler.
- (void)uploadTicket:(GDataServiceTicket *)ticket
finishedWithEntry:(GDataEntryYouTubeVideo *)videoEntry
error:(NSError *)error {
if (error == nil) {
NSString *url = [[[[video mediaGroup] mediaContents] objectAtIndex:0] URLString];
}
}

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.