Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Graph API - Creating new photo album for facebook app

I'm trying to create an album on my Facebook app using the Graph API. It's quite easy to create an album for a user account. We just need to have a user access token and send a post request for

https://graph.facebook.com/USER_ID/albums { name :'my USER album' }

It seems to be logical sending the same post request for app: https://graph.facebook.com/APP_ID/albums { name :'my APP album' }

However it doesn't work. I use the app token which I get from: access token tool.

Does anybody know how can I do this?

like image 933
michaltaberski Avatar asked Nov 28 '11 16:11

michaltaberski


2 Answers

I found a solution. It's quite wird, but what can I do.

Only a user who is an admin of the app can create new albums and photos. If you meet this criterion your app needs to request the user for one more permission: manage_pages.

After this you can request http://graph.facebook.com/ADMIN_USER_ID/accounts. There you will get an array of all pages managed by this user. Find en element which contains your APP_ID. The same element contains an access_token which is required to perform create album and upload photo actions.

like image 106
michaltaberski Avatar answered Oct 20 '22 20:10

michaltaberski


Quite simple solution detailed on the facebook Authentication documentation.(Scroll down to "App Login")

You have to query this url :

https://graph.facebook.com/oauth/access_token?
 client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET&
 grant_type=client_credentials

the response will be an access token that you can use to perform actions on behalf of you app.

like image 24
Lix Avatar answered Oct 20 '22 20:10

Lix