Posting photo from Android app directly to Facebook Page timeline - facebook

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".

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/

Related

Facebook RestFB publish a post/milestone along with photo to page

I am trying to post a feed on page along with photo,text posts without any error but picture doesnt get uploaded.
Also similar to Milestones it gets posted but how do i attach/upload a photo to it.
I am trying to Post a Milestone on FB using RestFB.
FacebookType publishResult = facebookClient.publish("pagename" + "/milestones",
FacebookType.class,
BinaryAttachment.with("photo", fileToUpload),
Parameter.with("title", title),
Parameter.with("picture", ""),
Parameter.with("description", description),
Parameter.with("start_time", new Date())
-......
But it posts the milestone without posting photo
It appears this is a (deliberate?) limitation of the Facebook Graph API. See Upload image to Facebook Wall / Feed via Graph API
You may post image data directly to a photo album but the feed endpoints only accept image URLs.

Post Photos to an album but hidden on the timeline using the Facebook Graph API

Is there a way to post a photo to an album, but do it in a way that it is hidden from the Timeline.
I am able to post Photos using the Graph API to the album and then manually go and hide a newsfeed post resulting from the timeline for the Wall.
Is it possible to do this at the time of posting the Photo itself. Is there a field/attribute that I can set which will prevent the Photo Post from showing on the Timeline ?
Thanks!
Yes, add no_story:1 to your POST data, images will be uploaded but not shown in timeline.
check out http://developers.facebook.com/blog/post/482/

Upload photo to fanpage from application user

I have a Facebook application in which a user can upload photos to a facebook fanpage. I am having trouble figuring out how to upload the photo as the user that is using the application. Currently I can have the fanpage upload the photo as itself, so the fanpage loses the author of the photo.
To do this I am grabbing the fan page's auth token(which I am assuming is the reason the app is posting as the fan page) and using that to pass to the "photos" method of the api. I am using the AS3 api, but I am sure the concept is the same no matter which api I am using.
var values:Object = {message:"message here", name:"title here"};
values.access_token = fanPageAccessToken;
values.image = file;
Facebook.api('fanPageId/photos/', handleUploadComplete, values,'POST');
When I change to the user's access token the image is uploaded to the user's photos. Even though I am specifying the fanPageId, it gets uploaded to the user's photos.
I am struggling here. Does anyone have an idea I can try, or some insight to share?
Thank you so much, I appreciate your time!
I've tried every possible API combination to post a photo to a page from the user, but it's no use. A user cannot post a photo to a page. Even creating an album on the page and then posting to that doesn't work.

Posting a Photo ( with caption ) to a FanPage Wall as a User using JavaScript SDK or Php SDK

I would like to do the following:
As a user, post a photo ( with caption ) to a FanPage Wall such that
on the FanPage Wall, I can see who ( which user ) have made that photo post.
( and also via the Graph API, i can see which user have posted the Photo,
not via the Facebook App )
I would like to do it via the Graph API, either using the PHP sdk or JavaScript SDK.
How do i achieve the objective?
I have currently tried the following tutorials:
1) http://developers.facebook.com/blog/post/498/
This works, but the example is for posting a photo to a User Wall.
I changed the code such that the UserID (me ) is now the FanPage Id.
It works, ( since the user is the admin and have liked the FanPage ).
But the issue is that the photo does not show up on the wall. Instead it shows up
with an attachment icon.
The following screenshot shows what i meant:
2) http://www.webspeaks.in/2011/12/upload-photos-to-facebook-fan-page.html
This works fine, but as the title says, it uploads photos to a album_id. I used the album_id of the Wall Photos, but after uploading the photo successfully, I am unable to find out
who ( which facebook user ) uploaded the photo.
However, if a facebook user logs into Facebook, like the FanPage, and posts to the FanPage Wall, i can find out which user made that post.
Any advice or suggestions?
Thanks a lot!
Best.
NOTE: the User is not an admin of the FanPage.
I think this is impossible to achieve, because to create a photo in a facebook page, you need to have manage_pages permission. It means you have to be the administrator of the page. All photos uploaded to facebook wall album are created on behalf of the page, not the user who upload them. You can see this using facebook graph explorer, examine the "from" field of the json result obtained from wall album.

app upload picture to specific album without posting on page wall

How to post a picture to a specific album in page from app without posting the image on page wall? Currently I can post picture to a specific album, but I don't want to see that on page wall becouse the app will post a lot of pictures. So how that is possible?
This is an example of app that uploads generated picture to specific album but dosn't publish it on its wall, I'm trying to do the same.
http://www.facebook.com/MercedesBenz?sk=app_318742408161371
Yes this is possible by providing no_story parameter equal to 1 while uploading photo.
POST https://graph.facebook.com/ALBUM_ID/photos?no_story=1
This information once was documented for photo object, but not anymore exists in current documentation.
This is described in Developer Blog post: Suppressing auto-generated feed stories when uploading photos