I am working on the API for a mobile application, which for the sake of argument is much like Foursquare and Instagram. Both of those applications will allow you to upload photos to your Facebook profile.
These will be added to a "Foursquare Photos" album, which will be made if it does not exist and you see it in your "Albums" area. Every time you add a new image it will become the album cover and you will see it displayed at the start of your album, so that images are in reverse chronological order (newest at the top/left, oldest bottom right).
To set the cover I assumed I could simply do this:
That is my attempt to post an update to the album ID, setting cover_photo as the photo ID of a file I've just uploaded. I have created the album fine, uploaded the photo fine all using the same access token - so we know it's not scopes (because yes I definitely have user_photos on the token).
A second approach was to assume this is automatic and try uploading a photo to the "start" of an album using the "position" field, but when I make a POST it seems to be completely ignored:
$photo = $facebook->api("/{$album_id}/photos", 'POST', array(
'access_token' => $token->oauth_token,
'image' => '#'.$filename,
'no_story' => 1,
'position' => 1,
'from' => array(
'id' => $user_opp->user->facebook_uid,
),
));
That uploads the image fine, but puts it at the end of the album, not the start.
So, how the f**k does this work? I've Googled my arse off and got nowhere. Tried the IRC and had no response, tried the Facebook Developer forums and they're down. I don't have any goats to sacrifice but maybe somebody out there knows.
Every time you add a new image it will become the album cover and you will see it displayed at the start of your album
That should happen automatically. And in my tests, it does.
A second approach was to assume this is automatic and try uploading a photo to the "start" of an album using the "position" field, but when I make a POST it seems to be completely ignored
That was never intended as a parameter for posting new photos, it was only returned when reading an albums photos from the API; and besides,
https://developers.facebook.com/roadmap/#october-2012
Removing position field for photos: The position field in both the photo FQL table as well as the Photo Graph API object will start returning 0 for all photos. The photos connection on an Album object in the Graph API will continue to return photos in the order they appear in the album.
Related
I am trying to upload local images directly to a pages feed (i.e. "Wall Photos" album).
This is the code that I think should work:
<?php
$facebook = new Facebook(array(
'appId' => $the_app_id,
'secret' => $this_app_secret,
));
$facebook->setAccessToken($the_access_token);
$facebook->setFileUploadSupport(true);
$attachment = array(
'message' => $the_post_body,
'name' => $this_image_name,
'picture' => '#' . $the_absolute_path_to_image
);
$result = $facebook->api('/me/feed, 'post', $attachment);
But this code just yields a plain text wall post with the contents of "message" (i.e. picture field is seemingly ignored). I have also tried "/page_id/feed", same result.
Now, simply changing the endpoint to "/me/photos", does upload the photo to a 'normal' album with the name of the app, but I want it to look as much like a normal post as possible and so hence into the "Wall Photos" album).
I realise that I could achieve this by querying the graph with FQL to find the object_id of the "Wall Photos" album, but if it does not exist it would require extra permissions to create it and I would rather keep permissions as simple as possible.
If anyone could point out how to upload photos to "/me/feed" I would greatly appreciate it.
But this code just yields a plain text wall post with the contents of
"message" (i.e. picture field is seemingly ignored). I have also tried
"/page_id/feed", same result.
You can only give the link to picture but not the data.
Now, simply changing the endpoint to "/me/photos", does upload the
photo to a 'normal' album with the name of the app, but I want it to
look as much like a normal post as possible and so hence into the
"Wall Photos" album).
Ye, it creates an album by default based on app. if already exists, it uploads to album. And generates a post.
I realise that I could achieve this by querying the graph with FQL to
find the object_id of the "Wall Photos" album, but if it does not
exist it would require extra permissions to create it and I would
rather keep permissions as simple as possible.
You cannot upload to fb for me/feed end point. You should store in your server/s3/some service and give the public url to me/feed params.
I am working on an app that creates albums in Facebook and then adds photos to the album. That side of things is working fine.
When the photos are added to the album facebook puts on the users timeline* something like " has added new photos to the album ."
What I would like to do is suppress this message, or at least customize it a little.
Does anyone know if this possible with the Facebook API? I have not been able to find anything in their doco, and suspect it is a automated thing that facebook doesn't give control over, but would like to get confirmation.
Cheers!
*not 100% sure if this is strictly the "timeline" or just their wall.
Use the no_story = 1 parameter.
$newphotodata = array(
'access_token' => $fanPageAccessToken,
'message' => $message,
'no_story' => 1,
'aid' => $albumId,
'image' => '#' . $picturePath);
$uploadedphoto = $facebook->api('/' . $albumId . '/photos/', 'post', $newphotodata);
I am working on this topic myself at the moment. This is my latest on it: http://facebookanswers.co.uk/?p=322
Incidently, have you worked out a way to generate a proper timeline post when you create a new album. If you do it manually, you get a nice post showing four of the images. But if you use the API you cannot get that. You can nearly get it by posting to /links/ but its still not quite right, as friends will just see a single icon.
Well, looking at the facebook api I can find no mention of how to suppress these automated status updates. From this I have concluded that it is not possible to modify or suppress these status updates.
Thinking about it some more I can understand why facebook would not these messages suppressed or changed as it could be abused by apps to make posts without a user noticing.
Just close the window after uploading and open again IE.
I am trying to create an application that posts specific information on a user's wall. This message should also be visible in the newsfeed, but this part is where it goes wrong.
I 'post' following information to the feed graph:
<?php
array(
'link' => string 'https://www.facebook.com/page' ,
'picture' => string 'http://...../picture.png' ,
'name' => string 'Name' ,
'caption' => string 'caption' ,
'description' => string 'info text' ,
'message' => string 'message'
)
?>
(All the information is filled in with usefull information, but for this question I made it quicker readable).
The information comes on the user's wall, but not in the news feed. This happens also from the user's side of the story: He can see the post on his wall, but not in any feed. Also when we try with other friends.
I also tried to only post a message (without link and picture), but it still is not visible in the general newsfeed.
The auth permissions are set and available (publish_stream) and the permissions are also correct when I look at them on the wall. I use the same code as an older app. Maybe it is a setting on the developer page? Sandbox mode is off...
Can somebody please help me?
Thank you!
I think it may be releated to the fact you're sending a link, apparently FB doesn't like this anymore :
"
Updating a User's Status
You can use this method to simply update a user's status. When you do so, the status message appears at the top of the user's profile and on the Friends > Status Updates page. The message also appears in the stream with your application icon.
To use this method to set a user's status do the following:
* Do not include an attachment or action link. If you do, the story will get published and will appear in the stream and on the user's Wall only. It won't appear at the top of the profile or in the Status Updates page.
* Make sure the message is no longer than 420 characters. Otherwise, an error gets returned.
"
as per http://developers.facebook.com/docs/fbjs/streamPublish/
What Facebook chooses to display on the newfeed is done via algorithm. There are options each user can set to view items in the news feed. Recent Stories first and Popular stories first. If the popular is selected, then facebook algorithms kick into overdrive. If recent stories, then it should display all available stream items (based on other privacy settings) into the feed.
Read this if your still wondering why auto posts and api feeds are not showing on the main news feed to others! Facebook dont like us saving our time they want us to sit on there site and supply quality posts and not focus on our own website!
https://developers.facebook.com/docs/public_feed/
When getting the "me/home" stream there is a difference between the photo objects i get in return. Some of them are returned with the source field (URL to the actual picture) and some not.
After investigating i learned that for photos uploaded to Facebook using the website itself there is the source and images fields in the object,
But for photos uploaded to Facebook by some kind of app (has the "application" field) there are no source/images fields, only a "link" field which direct me to the photo page (whole page, not just the photo)
Does that means i cant get the actual picture file for pics uploaded by apps ? am i missing something?
Update: The photos without the source field are "public".
You can use FQL to get very detailed information about the photo
SELECT src_big FROM photo WHERE pid='{photoId}'
For more information on what you can get from the FQL table see: http://developers.facebook.com/docs/reference/fql/photo/
Note: the quotes around the photo id is required as it is a string value
I am successfully uploading photos with my iPhone App and the corresponding Graph API calls, and it ends up properly in an (automatically created) album "appName Photos" on a new account w/o existing albums. Uploading to my own account, however, puts the photo to "Camera + Photos", the first of multiple albums existing for my account, instead of creating a new one for my app.
Anything I need to consider specifically to enforce creation of an app-related album? Do I need to go through an explicit album creation process first? I thought all the required information would be provided by the logon procedure, containing the appID (and seemingly does when using the "empty" account)?
EDIT:
I just had the albums programmatically listed, and actually an according album WAS created and is returned in the list of albums now, however it does not show up and contains no photos. So maybe it is rather a bug that the actual upload is taking place to the next album in the row (maybe some race condition on the FB side)?
Thx for insight, habitoti
By default, it should work that way (as described in the docs) but it appears to be a recent change to no longer enforce creation of an app-related album but to use a default album for all posted photos that aren't explicitly added to a specific album.
You'll want to use the procedure described here (look at the second chunk of code) to ensure that it creates an application-named album.