问题
I am using ASIHTTPRequest to work on Facebook graph API.
This is the nearest I have gone to posting a picture on the feed. So if I have a
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
The url is https://graph.facebook.com/me/feed
Now to post a picture I do the following:
[request setPostValue:@"My Message" forKey:@"message"];
[request setPostValue:@"somepic.png" forKey:@"picture"];
[request setPostValue:@"Some Name" forKey:@"name"];
[request setPostValue:@"Some description" forKey:@"description];
[request startAsynchronous];
If you try this then everything works fine other than the picture being posted. A blank placeholder for the picture is though show on the feed.
回答1:
Just use this small snippet to upload a image on your disk as raw data
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setData:UIImageJPEGRepresentation(img.image, 0.1) withFileName:filename andContentType:@"image/jpeg" forKey:@"photo"];
回答2:
I found out this documentation on facebook: http://developers.facebook.com/docs/reference/api/post
According to this documentation we can not post an image residing on our machine using the api. Instead we have to upload the pic and then provide the link for posting to the feed.
But uploading an image on to the wall is allowed if you logon to facebook.com. I believe this functionality is not provided in the graph api.
回答3:
It might be worth taking a look at ShareKit - http://www.getsharekit.com/
Their demo app publishes a photo on the Facebook wall successfully. I believe they wrap the upload-then-publish process in their code.
HTH, Oded
来源:https://stackoverflow.com/questions/3152413/posting-picture-on-facebook-feed-from-an-iphone-app