I would like to post a photo to the Timeline of a Facebook Page via Graph API. My setup is node-based and written in coffeescript. My current implementation is this (error handling ommited):
sendImageToFacebookTimeline = (user, message, imageURL, callback)->
url = "https://graph.facebook.com/#{pageID}/photos"
params =
access_token: user.accessToken
url: imageURL
message: message
request.post({url: url, qs: params}, (err, res, body)->
body = JSON.parse(body)
callback(body.id)
)
This succesfully posts the photo to my Page. But instead of appearing on the timeline it appears in the "Photos of PAGE".
How can I post to the Timeline?
EDIT:
I found out that by posting to /page_id/feed with option "picture" you can send a photo to Timeline. This shows up the same way as og:image and the view is similar to a link.
EDIT 2:
If you upload to a album, it will show up on Timeline. I have created an album and trying to post to it. But the API doesn't seem to accept URL for source when posting to /album_id/photos.
To post to own Timeline you need to acquire Page access token from /me/accounts and not by getting a user token or exchanging token for a long term token.
With that and album ID you can post to an album, which shows up on the Timeline.
Related
Sharing facebook photo (really a facebook photo) using mobile web app & Feed Dialog.
The problem: Cannot send facebook's photo to the Feed Dialog.
All code works great. I get all properties as they sent to the function.
FB.ui
method: "feed"
link: 'url'
app_id: myAppID
name: 'photo's name'
description: ''
caption: $('#albumName').text()
picture: 'http://myUrl.com/logo.png'
, (response) ->
if response and response.post_id
console.log 'Photo was shared'
else
console.log 'Photo was not shared. Please try again'
If I place a static photo, to represent the Picture parameter, all goes fine, But if I try to call a facebook picture I try to share, then I get a 500 server error.
GET
https://www.facebook.com/dialog/feed?access_token=...662390597_s.jpg&sdk=joey
500 (OK)
This is totally bizarre. The URL that goes to the dialog iframe, goes with all the needed parameters, including access_token.
It seems like a design issue. Like someone in facebook don't want us to pretend to be facebook when we customly share things using their feed dialog, when we share facebook photos.
Am I right?
* Problem Solved. See my answer below *
!!! Problem Solved !!!
Facebook don't accept their own CDN as a source. We need to bypass that in order to share, therefore we can reshare a facebook the photo using a proxy.
http://images.weserv.nl does the job. Facebook accept the image as a picture param, and this way you are able to reshare their posts.
Usage example (plus width and hight to improve performance)
'https://images.weserv.nl/?url=' + facebookImageUrl + '&h=200&w=200'
I can't share facebook photo use this example
when i share with (fb.ui method feed) i get 404 error on this link
https://fbexternal-a.akamaihd.net/app_full_proxy.php?app=460125687444228&v=1&size=z&cksum=047536ba625482c9b5343f2eb94a7039&src=https%3A%2F%2Fimages.weserv.nl%2F%3Furl%3Dhttps%253A%252F%252Ffbcdn-sphotos-b-a.akamaihd.net%252Fhphotos-ak-ash4%252Ft1.0-9%252F10157304_1383818341898181_8685912667835736794_n.jpg%26h%3D200%26w%3D200"
"app=460125687444228
cksum=047536ba625482c9b5343f2eb94a7039
size=z
src=https://images.weserv.nl/?url=https%3A%2F%2Ffbcdn-sphotos-b-a.akamaihd.net%2Fhphotos-ak-ash4%2Ft1.0-9%2F10157304_1383818341898181_8685912667835736794_n.jpg&h=200&w=200
v=1"
Where my error ?
I use node.js to handle Graph API, and post feed, link normally on the Facebook page wall.
But if I post a photo to page, it cannot use page role.
The photo will be posted with my Facebook user, and shown on the other side.
So, how can I post a photo to page wall with page role via Graph API
--
POST https://graph.facebook.com/#{page_id}/photos?access_token=#{access_token}
With Parameters
{
message: 'the message'
url: 'the image url'
}
OR use multipart/form-data
{
message: 'the message'
source: 'post file'
}
same result, help please.
The access token has manage_pages, public_stream permissions.
Useful feed post
POST https://graph.facebook.com/#{page_id}/feed?access_token=#{access_token}
{
message: 'something interesting'
}
this will show on page's wall as page role
If you want to act as the Facebook Page itself, you will need to pass an access token for it. I put details on that in here: https://stackoverflow.com/a/16576107/183880
It's for PHP, but the basic concept should get you where you need to go.
Assume that I have know about FB API, I just want to ask "any way to upload album to FB from my website?".
Ex: xkcn.info/archive is my website, I develop a checkbox function that allow user can mark pictures and upload to facebook, it create an album or photo...;).
Thank a lot.
Yes of course it is possible.
First of all you need the permissions:
user_photos to get the access to the user's album
publish_stream to post photos to an album
You can create an empty album of a page by issuing an HTTP Post request to me/albums with following parameters:
name- The name of the album
message- The description of the album
In return you will get the album_id which you can use to post photos into
You can add photos to an album by issuing an HTTP POST request to ALBUM_ID/photos with following parameters:
source- Photo content (multipart/form-data)
message- Photo description string
Reference: Album
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.
Here's what I've done:
Get page access token from /me/account
Paste in on the graph explorer tool.
Make a post request with parameters named message, url (trying to upload via url) to http://graph.facebook.com/{albumid}/photos.
Graph returned a Id.
Figured out the problem. We need to approve the photos from by going to the album as the Page.