How to add photo from my android application to my facebook album page
I have an android application that creates an image.
I would add this image in an album of my facebook page (and not in my personal wall).
I see that i must use the app token.
i get the app token with:
https://graph.facebook.com/oauth/access_token? client_id=MY_APP_ID &client_secret=MY_APP_SECRET &grant_type=client_credentials
And then with this app token I think that i must use this code:
String appToken="MY_APP_TOKEN"; facebook.setAccessToken(appToken); Bundle parameters = new Bundle(); parameters.putString("caption", "This is a message test..."); byte ImageBytes=...; parameters.putByteArray("photo", ImageBytes); String response2=facebook.request("ALBUM_ID/photos", parameters, "POST");
This code return this error:
A user access token is required to request this resource
Then i must not use app token? Thanks
Yes, you need an user access token to make API requests on behalf of the user. You should use our Facebook Android SDK to provide an easy way for users to authorize your app. Our SDK also makes it easy to fetch the access token after the user authenticates, follow our Android tutorial here if you have more questions.
App access tokens are different from user access token, this is taken from the documentation.
Authenticating as an App allows you to obtain an access token which allows you to make request to the Facebook API on behalf of an App rather than a User. This is useful, for example to modify the parameters of your App, create and manage test users, or read your application's insights for example.
Let me know if that answers your questions.