i'm trying to post an image on facebook using the following code.
FBStreamDialog* dialog ;
if([FBSession session].isConnected)
dialog = [[[FBStreamDialog alloc] initWithSession:[FBSession session]] autorelease];
else
dialog = [[[FBStreamDialog alloc] initWithSession:session] autorelease];
dialog.attachment = [NSString stringWithFormat:@"{\"name\":\"%@\",\"media\":[{\"type\":\"image\",\"src\":\"%@\"}]}", strEventStatus,eventImg];
[dialog show];
Does the media tag have any other property apart from src which would take and image in form of N开发者_开发百科SData? how do i post the image otherwise?
While you are linking the attachment property for a Image the source should be a URL.. I dont think You can post a UIImage by using attachment.. One solution is you can have a webservice for posting the image in your server and then give that URL when you are posting.
I dont know which Facebook API you are using.. This what i did to upload a image by using Facebook Graph API
UIImage *img = [UIImage imageNamed:@"myImage.png"];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
img, @"picture",
nil];
//facebook is a facebook Obj which I initialized before
[facebook requestWithMethodName:@"photos.upload"
andParams:params
andHttpMethod:@"POST"
andDelegate:self];
I have no knowledge of the Facebook API you are using, but it would seem Image SRC would imply that the image is already somewhere on the web.
Have you considered uploading the image to a server somewhere and using the SRC of the image as a URL?
I hope this helps!
You can directly take a UIimage
and upload via the code used by BuildSucceeded
, you no longer need to forward the image to a server and link via URL. You can also call the image from a UIimageview
, camera or library.
精彩评论