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.
Related
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.
I am trying to upload an image through my application with Facebook Graph API to an album of my fan page. Although I provide the albumID like a parameter for uploading the image, it is uploaded in an album named to my application name Photos on my own profile. The album of the fan page stays empty. I tried also with sending the pageID of my fan page instead of albumID, but the result is the same.
I thought there is a problem with access token but with same accessstoken i can post links to page.
The code I use for the upload is:
$args = array(
'access_token' => $access_token,
'message' => "$baslik",
"source" => '#' . realpath($file)
);
$post_id = $facebook->api("/$page_id/photos","post",$args);
Please give me ideas how can I upload the image to the fan page and not to my own profile album.
I think you havent got Manage Permission.
Check this for more info : Upload image to facebook fan page using API
Can I do something like this?
I want to have all the photos from my fan page, embedded on my website.
Want to have the option to like each photo - must.
Want that each photo will have a link to the real URL on Facebook - must.
Would like to share and comment as well but not as important.
Please let me know if you have an idea of how I can do it.
I saw a lot of examples but nothing that include these things.
Thanks!
Getting some of the photos is easy. Getting all of the photos is nearly impossible. Start with a Graph API call to the photos object.
To get the photos, create and app, install the PHP SDK on your site. This code should get you started.
$config = array(
'appId' => 'YOUR_APP_ID',
'secret' => 'YOUR_APP_SECRET',
);
if (!class_exists('Facebook'))
include_once 'PATH_TO_SDK/facebook.php';
$fb_object = new Facebook($config);
$photos = $fb_object->api('PAGE_ID_OR_USERNAME/photos', 'GET');
printf('<pre>%s</pre>', print_r($photos, true));
You'll need to iterate through these results to get more than 15 of your photos. Photos that aren't marked as "Public" won't be returned by this API call.
To create a like or a comment, you need to auth the user and then POST to the Graph API using the photo id.
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/