Possible Duplicate:
Upload photo to users profile from photo URL, not input file field
I have the access_token. It’s with the publish_stream permission.
Alright, now I want to upload an image to my default app’s album on Facebook. The image is hosted on my S3.amazon.com. (but for example purposes, let’s take this link: https://i.stack.imgur.com/DvlWa.jpg)
How can I upload this imgur image to my app’s album? (documentation on Facebook is weird, and I don’t understand PHP).
To upload photo to “Application Album” you have two ways (actually first may interest you more).
Option 1: Uploading Photos to the Graph API via a URL:
To achieve this you need to issue
POSTrequest (orGETwith argumentmethod=post) to next URL:http://i.imgur.com/Ptyzk.jpgin url encoded form ishttp%3A%2F%2Fi.imgur.com%2FPtyzk.jpg(you only need to encodeurlif you passing it withing URL arguments, and must not encode if you passing it with post-data).As stated in
photoobject documentation, by posting photo tohttps://graph.facebook.com/USER_ID/photos:Option 2: Uploading image data
You just need to issue
POSTrequest tohttp://graph.facebook.com/me/photos(see Create Photos section ofuserobject documentation).The only required parameter is
sourcewhich ismultipart/form-dataencoded file, you can either download it to temporary file and upload it later, or stream it to the Graph API (depending on technology you use to implement this functionality)There is couple of samples how to upload photo (in languages other than PHP):
Update:
It’s not really clear where do you want photo to be published User’s album or Application album (
titleandbodyof question are opposite on this). If you want to publish it to User’s album you need to replacemewithidof album you want photo be uploaded to. Otherwise useme(for current user) or other userid(this will require usage of applicationaccess_token).