adding photo on facebook wall - iphone

- (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.

Related

Share text with Images on Instagram in ios

In my App I sharing an image on Instagram. It is working well in my app.
I am using the following code.
#property (nonatomic, retain) UIDocumentInteractionController *dic;
CGRect rect = CGRectMake(0 ,0 , 0, 0);
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIGraphicsEndImageContext();
NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:#"Documents/test.igo"];
NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:#"file://%#", jpgPath]];
// NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:#"file://%#", screenshot]];
self.dic.UTI = #"com.instagram.photo";
self.dic = [self setupControllerWithURL:igImageHookFile usingDelegate:self];
self.dic=[UIDocumentInteractionController interactionControllerWithURL:igImageHookFile];
[self.dic presentOpenInMenuFromRect: rect inView: self.view animated: YES ];
- (UIDocumentInteractionController *) setupControllerWithURL: (NSURL*) fileURL usingDelegate: (id <UIDocumentInteractionControllerDelegate>) interactionDelegate {
UIDocumentInteractionController *interactionController = [UIDocumentInteractionController interactionControllerWithURL: fileURL];
interactionController.delegate = interactionDelegate;
return interactionController;
}
Now I also want to share some text with the image.
As shown in the Image below. In " Write a Caption", I want some default custom text for eg. "Share this photo".
How can I do this?
Thanks in advance...
Edited
I am opening Instagram from my app for sharing images and it works fine.
But Is it possible that Can I check Whether the user has shared it successfully or not?
Means I want to perform some action in my DB when user successfully shares an image.
How can i do this?
I got my answer. Just added a line and it worked for me.
self.dic.annotation = [NSDictionary dictionaryWithObject:#"Here Give what you want to share" forKey:#"InstagramCaption"];
Thanks...
It is also documented in the official documentation at http://instagram.com/developer/iphone-hooks/
To include a pre-filled caption with your photo, you can set the annotation property on the document interaction request to an NSDictionary containing an NSString under the key "InstagramCaption". Note: this feature will be available on Instagram 2.1 and later.
You are no more allowed to share Pre-Filled Text with Instagram or Facebook.
Only Images/Screenshots can be shared via UIDocumentInteractionController.

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.

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

write a message on wall of facebook using my iphone application

I am making an iphone game , In that I want to upload score on face book. I am new to face book codes, I've got it's API from github.com. But I don't know how to write or post directly my message on wall of face book of log in account else how to share my score on facebook. I've done log in portion.
Can any one help me????
Please refer the facebook api development at http://wiki.developers.facebook.com/index.php/Facebook_iPhone_SDK
Sample application also given by facebook for iPhone.
Thanks,
Jim.
Assuming the user has allready logged in and you have a vaild faceb0ok session, you could use something like this to get you started:
- (void) post {
postingDialog = [[[FBStreamDialog alloc] init] autorelease];
postingDialog.delegate = self;
postingDialog.userMessagePrompt = #"Prompt the User:";
NSString *name = #"Name of thing"
NSString *href = #"http://www.example.com"
NSString *caption = #"This is a caption"
NSString *description = #"This is a description";
NSString *imageSource = #"http://example.com/1.png";
NSString *imageHref = #"http://example.com/1.png";
NSString *linkTitle = #"Link title";
NSString *linkText = #"Text";
NSString *linkHref = #"http://www.example.com/iphone";
postingDialog.attachment = [NSString stringWithFormat:
#"{ \"name\":\"%#\","
"\"href\":\"%#\","
"\"caption\":\"%#\",\"description\":\"%#\","
"\"media\":[{\"type\":\"image\","
"\"src\":\"%#\","
"\"href\":\"%#\"}],"
"\"properties\":{\"%#\":{\"text\":\"%#\",\"href\":\"%#\"}}}", name, href, caption, description, imageSource, imageHref, linkTitle, linkText, linkHref];
[postingDialog show];
}