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

Answers


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.


Need Your Help

manupulate url in MVC2

asp.net-mvc-2 url

On my page I have a lot of textpages and to save some time. I would like to make one controller/Action to handle all this sites. However, this gives me some problems with the URL (I dont want it to...

Facebook Login Popup Box Blank

javascript facebook api facebook-graph-api facebook-javascript-sdk

After making a quick static landing page we noticed that the facebook login does not work. It simply pops open a box and then automatically redirects before being allowed to sign in or decline.