Share image on facebook using FBConnect
After searching 2 days on it m finally posting my开发者_JAVA技巧 code.
Application Description: I am choosing an image through imagePicker and after editing it I want to share it on Facebook.
Problem: I can post the text on my wall but not the image, as i dont have any URL i cant find another way to post image on my wall.
here is the code ( which i stole from another application) of my PostToWall
FBStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.userMessagePrompt = @"Enter your message:";
dialog.actionLinks = @"[{\"Get DowntownLA!\",\"href\":\"http://www.facebook.com/DowntownLA.com/\"}]";
dialog.attachment = [NSString stringWithFormat:
@"{ \"name\":\"%@\","
"\"href\":\"%@\","
"\"caption\":\"%@\",\"description\":\"%@\","
"\"media\":[{\"type\":\"image\","
"\"src\":\"%@\","
"\"href\":\"%@\"}],"
"\"properties\":{\"%@\":{\"text\":\"%@\",\"href\":\"%@\"}}}", @"name: priya",@"href nothing",@"cation nothing",@"description nothin", @"imageSource nothing ", @"imageHref nothing", @"linkTitle nothing", @"linkText nothing", @"linkHref nothing"];
[dialog show];
Please tel me wher m going wrong !!!!!
The error m getting on simulator is : Application Response Error - The post action links must be valid URls. You can see this because you are one of the developers of the app.
i have upload image in this way
- (void) postOnFBWall
{
NSMutableDictionary *variables = [NSMutableDictionary dictionaryWithCapacity:2];
//create a UIImage (you could use the picture album or camera too)
UIImage *picture = imgUploadPhoto.image;
//create a FbGraphFile object insance and set the picture we wish to publish on it
FbGraphFile *graph_file = [[FbGraphFile alloc] initWithImage:picture];
//finally, set the FbGraphFileobject onto our variables dictionary....
[variables setObject:graph_file forKey:@"file"];
NSString * messageValue = [NSString stringWithFormat:@"Menu Name: %@, Restaurant: %@, Category: %@, Comment: %@",txtNameofMenu.text,txtRestaurant.text,categoryLbl.text,txtViewComment.text];
[variables setObject:[NSString stringWithFormat:@"%@",messageValue] forKey:@"message"];
//the fbGraph object is smart enough to recognize the binary image data inside the FbGraphFile
//object and treat that is such.....
FbGraphResponse *fb_graph_response = [[FBRequestWrapper defaultManager] doGraphPost:@"me/photos" withPostVars:variables];
NSLog(@"postPictureButtonPressed: %@", fb_graph_response.htmlResponse);
}
精彩评论