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:
App developers who host their images on Amazon S3 or a similar service can pass the S3 URL directly to Facebook without having to download the file to their application servers only to upload it again to Facebook. This improves performance and reduces costs for developers.
To achieve this you need to issue POST
request (or GET
with argument method=post
) to next URL:
https://graph.facebook.com/me/photos?
access_token=...&url=http%3A%2F%2Fi.imgur.com%2FPtyzk.jpg
http://i.imgur.com/Ptyzk.jpg
in url encoded form is http%3A%2F%2Fi.imgur.com%2FPtyzk.jpg
(you only need to encode url
if you passing it withing URL arguments, and must not encode if you passing it with post-data).
As stated in photo
object documentation, by posting photo to https://graph.facebook.com/USER_ID/photos
:
The photo will be published to an album created for your app. We automatically create an album for your app if it does not already exist. All photos uploaded this way will then be added to this same album.
Option 2: Uploading image data
You just need to issue POST
request to http://graph.facebook.com/me/photos
(see Create Photos section of user
object documentation).
The only required parameter is source
which is multipart/form-data
encoded 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 (title
and body
of question are opposite on this). If you want to publish it to User's album you need to replace me
with id
of album you want photo be uploaded to. Otherwise use me
(for current user) or other user id
(this will require usage of application access_token
).