Post Image on friends facebook wall

P

Note: Remember one thing image is a file and if you want to post a file on your friends wall then in that case you have to make use of a class named “FBGraphFile”.

– (IBAction)postImageButtonclicked:(id)sender
{
if (fbgraphref!=nil)
{
NSMutableDictionary *variables = [[NSMutableDictionaryalloc]initWithCapacity:2];
FbGraphFile *fbfile = [[FbGraphFile alloc]initWithImage:imgv.image];
[variables setObject:fbfile forKey:@”file”];
[variables setObject:@”iPhone by radix” forKey:@”message”];
[fbgraphref doGraphPost:[NSStringstringWithFormat:@”%@/photos”,self.friendID] withPostVars:variables];
UIAlertView *objAlert = [[UIAlertView alloc]initWithTitle:@”Alert”message:@”Data Posted on friends wall” delegate:nil cancelButtonTitle:@”OK”otherButtonTitles:nil];
[objAlert show];
[self.navigationController popToRootViewControllerAnimated:YES];
}
}
Code Explanation: In the above code i am using the class FBGraphFile and storing the image data that i want to send to my friends wall.
Then with the help of dictionary i am encapsulating the image and some text about the image.
Later with the help of the FBGraph object i am posting the image and the text data regarding that image  with the help of the method named doGraphPost also make a note that this time its not the feeds that i am using its the photo variable since we want to push a photo on our friends wall.
Now when everything is in place you may run the application.
Now select a friend from the list and when you do you will be navigated to the following screen.
Now when you tap on the Post Image button then the image which is currently selected by you will be posted on your friends facebook feeds.
Later you may login to your facebook account and check your friends wall just in case to see if the image is loaded or not
You can download the source file from here.

About the author

mayur.kore
By mayur.kore

Category