1
votes

I have an Android app from which I'd like to post photos directly to the timeline of a Facebook Page. I don't want the photos to go into an album, but rather directly onto the timeline.

Has anyone done this before?

I saw the answer at http://facebook.stackoverflow.com/questions/8662460/android-app-how-to-upload-photo-from-sdcard-to-facebook-wall that describes posting the photo to a Wall Photos album; however, when I try get the list of albums for the Page, I don't get any albums back. This page does have least one timeline post with a picture, so I would expect it to have a Wall Photos album, but I don't get it back. Do the albums work differently for Pages as opposed to a regular Facebook user, or would the Page need to grant the app some permissions? Here is the code I'm using to get the Page's albums:

String wallAlbumID = null;
String response = getFacebook().request("<pageid>/albums");
JSONObject json = new JSONObject(response);
JSONArray albums = json.getJSONArray("data");
for (int i =0; i < albums.length(); i++) {
    JSONObject album = albums.getJSONObject(i);                     
    if (album.getString("type").equalsIgnoreCase("wall")) {
        wallAlbumID = album.getString("id");
        Log.d("JSON", wallAlbumID);
        break;
    }
}

Does anyone know of a way to post a photo directly to a Page's timeline from an Android app? I can upload the photo to the user's album, then create a link to the photo on the Page's timeline, but that doesn't actually put the photo on the Page's timeline. I'd like to get the photo right on the timeline, like what happens from the Facebook web interface when you click "Upload Photo".

1

1 Answers

0
votes

An photo posted to Facebook will always fall into an album. If you don't specify an album ID from the user's list of albums, uploading images will automatically get uploaded to the "Wall Photos" album instead.

Use the publish_stream method to post a photo to the timeline, and it will show up on the timeline and in the Wall Photos album. Or use the feed dialog with just a picture: https://developers.facebook.com/docs/reference/dialogs/feed/