Home Facebook Graph API: Uploading Photo to specific album
Reply: 0

Facebook Graph API: Uploading Photo to specific album

user7247 Published in September 19, 2018, 11:16 am

I'm trying to upload photos to a specific album of the authenticated Facebook user. But the photo does not appear in the album. It appears in a new album named '"appname" Photos'. I'll try to describe my way as complete as possible - maybe this helps you out there to find my mistake.

I'm not using any Facebook or third party SDK. The project programming language is C# (if it matters).

First of course, I'm getting an access token, by sending the user to the following URL:

  • {0}: The client ID: my application ID, as provided by Facebook
  • {1}: The redirect URI, set to 'https://www.facebook.com/connect/login_success.html', as I'm working on a desktop application
  • {2}: The response type: 'token'
  • {3}: The scope - all the privileges I'm requesting. This is a comma separated list of the following items:
    • manage_pages
    • email
    • user_about_me
    • user_photos
    • user_videos
    • publish_actions
    • publish_stream
    • user_likes
    • user_activities
    • user_groups
    • photo_upload
    • video_upload

The list of privileges is not only meant for the photo upload.

The login and it's implementation works quite well, so that I get an 'access_token' and an 'expires_in' field in the answer.

If I don't have it already saved, I'm getting the user ID of the authenticated user represented by the access token. This is done by a simple request to:

  • {0} is the acquired access token

This also works quite well and I get a positive response with name, e-mail etc. and the user ID.

Next Task, get the list of albums the user associated with the acquired access token and the user ID. This is done by a FQL query:

SELECT aid,can_upload,created,name,description FROM album WHERE owner={0}
  • {0} is the user ID

The FQL query is executed by calling this URL:

  • {0} the query from above
  • {1} the access token

Again, this works quite fine - I get the requested fields back. The 'aid' values are used as album IDs later and are in the format 99999999_999999999 (numbers with an underscore somewhere in the middle). I only use albums that have the can_upload flag on "true".

Now, I hope I have all the information I need to publish the photos.

I create a POST request, multipart/form-data, to this URL:

  • {0} is the 9999999_999999 album ID
  • {1} is the access token from the login

The request consists of two fields: 'source' contains the photo's binary data, 'message' the caption.

The request succeeds. No problem detectable for me.

But when I now visit the Facebook user page, the photos are not in the selected album, they are in an extra album named '"appname" Photos'. The caption is set correctly.

What must I change to bring the photos directly to the desired albums?

share|improve this question

2 Answers 2

active oldest votes
up vote 2 down vote accepted
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.305363 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO