I would like to publish more than one photo on Page Timeline, but do not see any way how to manage it. I can publish only one photo on Page Timeline or album.
Is there any chance how to upload multiple photos into Page Post in help with Graph API?
Edit: As found out, not worked successfully, because there were changes. More info here...
This is an old post, and I don't know if this method could work back in 2014, but in 2017 it's working. Unfortunately there's no way to create the post in one FB query, but there's a trick.
Step 1
Batch upload the images in silent mode, which means there will be no post on the timeline, just pure upload.
For this you have to use
'published' => false,
in the parameters, and
/me/photos
as the URL.
Step 2
After each upload FB will give you back the ID of the uploaded image. Grab those into an array:
$resparr[] = $graphNode['id'];
Step 3
After the uploads you will have an array of the image IDs. Let's format them for the FB post:
$phc = 0;
foreach ($resparr as $pid) {
$linkData['attached_media['.$phc.']'] = (object)array('media_fbid'=>$pid);
$phc++;
}
Step 4
Make an other call to the API, but this time the URL should be
/me/feed
This will create a public post which contains the images.
(You need a page access token for this to post onto a page, or a user access token to post your wall.)
More info # Faceook Developers.
Related
I am creating a facebook app that posts to a business Page (not a users own feed) and I am uploading photos to go along with my post. I am uploading the photo as opposed to providing a url for fetching.
I also want to schedule these posts up to two months in advance.
In this page of the facebook graph documentation it says "After you upload an unpublished photo, Facebook stores it in a temporary upload state, which means it will remain on Facebook servers for about 24 hours. If you do not publish these photos within 24 hours, we delete them."
Does this mean that I need to publish my photos in order to use them with scheduled posts? ie, if I upload an image and set it to unpublished, but then use it in a scheduled post that is scheduled for 5 days from now, will the photo be deleted before the post is posted?
I am trying to publish post to Facebook news feed (timeline) with Graph API.
I can use Facebook standard GUI messenger to publish post and add photos to this post. But how to make this from Facebook Graph API?
I can upload images to album and try to create link on this images. But can create only 1 link.
What is the correct algorithm to publish post with more than 1 picture added to this post?
As of now it is not possible to publish one post with multiple pictures. You need to create separate posts for each one of them, or put all the images together in one with your favourite server language and post it as single picture.
Actually you can upload a multi story photo(I did it using Graph Api and PHP) but the problem comes if you need scheduled this post.Your post is schedule but also it shows on the page's feed.
P.S. I'm using Graph Api v2.9
PHP Code
$endpoint = "/".$page_id."/photos";
foreach ($multiple_photos as $file_url):
array_push($photos, $fb->request('POST',$endpoint,['url' =>$file_url,'published' => FALSE,]));
endforeach;
$uploaded_photos = $fb->sendBatchRequest($photos, $page_access_token);
foreach ($uploaded_photos as $photo):
array_push($data_post['attached_media'], '{"media_fbid":"'.$photo->getDecodedBody()['id'].'"}');
endforeach;
$data_post['message'] = $linkData['caption'];
$data_post['published'] = FALSE;
$data_post['scheduled_publish_time'] = $scheduled_publish_time;
$response = $fb->sendRequest('POST', "/".$page_id."/feed", $data_post, $page_access_token);
$post_id = $cresponse->getGraphNode()['id'];
According to the documentation, it is possible to do so: https://developers.facebook.com/docs/graph-api/photo-uploads#publishing-a-multi-photo-story
The gist is to:
Upload photos but mark them as "unpublished", keep the ids
Create a "post" with those "unpublihsed" photos as attachments
Hope it helps.
I need to fetch videos uploaded by users to a Facebook Page.
I'd have expected them to show up in https://graph.facebook.com/me/videos/uploaded, but it appears this only covers videos I've uploaded to my profile, not to a page.
The only place I can find that these show up is https://graph.facebook.com/PageName/tagged, but there they're crammed in amongst all the other stuff and I can't filter to find just the authenticated user's uploads to the page.
Is there a way to get only a specific user's video uploads / tags to a page?
OK, if we’re just talking videos posted to the wall here, I guess you could get that info querying the FQL stream table.
Filter it by:
source_id: The ID of the page whose wall the post is on
actor_id: The ID of the user that published the post
type: "128" - Video posted
Information about the video should be in the attachment column.
I'd like to know if the following is possible using Facebook apps:
I'm using the Facebook SDK for .NET and want to create an app that a page will use. The app will take a photograph from a user who happens to visit the page, that photograph should then be sent to one of the page's photo albums.
I've managed to perform this successfully, but only when logged in as the page admin. If I log out of the page admin, log in as my personal Facebook account (as most users of the app will do) then the photograph never gets sent to the pages photo album.
I would like to do all of this when the user uploads the photo, but if it isn't possible I'll need to look into a separate process to actually send the photo's to Facebook, and just store the image on my server until the process runs.
The admin photo album (aka page photo album) is not the same album as non-page admins get to upload to (which is the wall). They are separate buckets all together.
As you mentioned, you can always just upload and store the photos on your server, and then just have a feed item that links over to that image.
I was trying to find this on facebook's site in their documentation but so far no luck. I'm sure others must have run into this before.
I use Amazon S3 for storing images. I didn't know ahead of time that if I named my bucket as my domain name with subdomain I could link that way, so until I move all of the pictures I have to link to mybucket.s3.amazonaws.com domain. When I include a picture from there with a post to the wall the picture doesn't show up. If I change the picture to one on the server itself the picture does show up. It seems that the domain name of the picture must match my app? I looked at bugzilla and didn't see this mentioned. Facebook's forum says to post questions here.
I'm using the C# Facebook SDK from CodePlex.
My code looks like (with error handling and authentication check removed):
var client = new FacebookClient(FACEBOOK_APP_ID, FACEBOOK_SECRET);
client.AccessToken = facebook.AccessToken;
var parameters = new Dictionary<string, object>();
parameters.Add("name", name);
parameters.Add("caption", title);
parameters.Add("message", message);
parameters.Add("link", link);
parameters.Add("source", link);
parameters.Add("picture", imageUrl);
client.Post("me/feed", parameters);
I verified that imageUrl does indeed have a correct picture, the domain name just doesn't match. The picture on amazon s3 has public read access. I can view it from my browser so I don't think it's a permission problem. I've tried a few different pictures with the same problem. Only time it's worked so far is when the picture was on the server itself.
So, my question is, is it a problem with me, or does facebook block images that don't match the domain name specified on the app?
You can upload the picture from that url, then add its object id in the post.
Refer to: http://developers.facebook.com/blog/post/526/?ref=nf
Uploading Photos to the Graph API via a URL
Earlier this year, we released support for uploading photos directly
via the Graph API. This requires sending the photo as a MIME-encoded
form field. We are now enhancing our photo upload capability by
introducing the ability to upload photos simply by providing a URL to
the image. This simplifies photo management for a number of use cases:
App developers who host their images on Amazon S3 or a similar
service can pass the S3 URL directly to Facebook without having to
download the file to their application servers only to upload it
again to Facebook. This improves performance and reduces costs for
developers.
Apps written on platforms that don't have good support for
multipart file uploads can create new photos more easily.
To upload a photo via a URL, simply issue an HTTP POST to
ALBUM_ID/photos with the url field set to the URL of the photo you
wish to upload. You need the publish_stream permission to perform this
operation. You can also include an optional message parameter to set a
caption for the photo.
I'am facing the same issue as well. Based on my observations it seems that facebook does not like it when the picture url has more than one sub-domain.
I tried the below 2 URL variations for the same image..
mybucket.s3.amazonaws.com - throws an error
s3.amazonaws.com/mybucket - works fine
:picture => 'http://mybucket.s3.amazonaws.com/footprints/15/coverimgs/medium.jpg'
OAuthException: (#100) picture URL is not properly formatted
:picture => 'http://s3.amazonaws.com/mybucket/footprints/15/coverimgs/medium.jpg'
{"id"=>"587472956_10150280873767957"}
Now i have to figure out how to change the URL structure for the image while passing it to the FB graph API.
I would log it as a bug. If this is really the case, which I kinda doubt, you could create a 301 redirect on your own domain for each image that redirects to the Amazon url.