I'd like to post a Link to Facebook using the Graph API, but I'd like to be able to avoid a thumbnail image. Facebook's web interface has a no-thumbail checkbox while posting an image; I'd like to simulate this from my own application.
I've tried specifying an empty string for both the source and picture arguments, but Facebook still fetches a thumbnail image for the specified link regardless.
For example, I've tried this, but a thumbnail image still shows up:
curl -F 'access_token=...' \
-F 'message=Link with empty source and empty picture' \
-F 'link=http://stackoverflow.com' \
-F 'picture=' \
-F 'source=' \
https://graph.facebook.com/me/feed
UPDATE: This support forum suggests that this is a bug with Facebook, and they suggest posting a 1x1 pixel clear image. I'd prefer a better workaround than this.
Since picture=0 no longer seems to work without throwing an error, here's another way, but it's a hack and not likely recommended. By skipping the picture argument and specifying a source argument that is a valid URL, but isn't an image, Facebook will render the post without the thumbnail. For example:
curl -F 'access_token=...' \
-F 'message=Link with empty source and empty picture' \
-F 'link=http://cnn.com' \
-F 'source=http://cnn.com' \
https://graph.facebook.com/me/feed
Facebook has now fixed this bug. Set picture to empty string or set picture=NULL, both should work now.
I talked with Facebook developers at F8 2011 and they agreed that this is a bug. I have filed this bug with Facebook in their new bug tracking system:
https://developers.facebook.com/bugs/231434760243248
If you want it fixed, upvote this question & answer!
Try using the value "0" for picture. This worked for us, it does show a gray bar next to the link information, but it doesn't pull in a default image and doesn't display the awkward whitespace when using a 1x1 pixel.
Hope this helps!
Now in June 2011 it seems the "picture=" parameter isn't required at all, and FB didn't pull one from the page either:
curl \
-F "message=test message, attempting to verify solution of SO problem" \
-F "name=StackOverflow" \
-F "link=http://stackoverflow.com/questions/4246170/how-do-i-post-a-link-to-facebook-without-a-thumbnail" \
-F "access_token=you_dont|reallythink|imgonnapostmyrealaccesstoken_doya?" \
"https://graph.facebook.com/11239244970/feed"
Result at SO's Facebook page: https://www.facebook.com/pages/stackoverflow/11239244970
It appears that if you specify a picture url where either the server is unreachable or the picture does not exist, the resulting post includes the grey bar as desired:
curl -F 'access_token=...' \
-F 'message=404 picture' \
-F 'link=http://example.com' \
-F 'name=Example' \
-F 'description=example.com is not about bbq' \
-F 'caption=example.com' \
-F 'picture=http://example.com/this/does/not/exist/1.gif' \
https://graph.facebook.com/me/feed/
For full disclosure however, I'm not using this solution in production because it seems hacky and I don't trust Facebook to allow this method to exist indefinitely.
put an invalid url image it's will "resolve" while the facebook not fix this bug.
the parameter is: "picture"
This had been disabled by Facebook and it's not a bug, it's by design as it's stated here by the FB team. They say they will remove the "No thumbnail" option from their site too, not just on the API. The thread I linked is the most recent (31 Dec 2015).
The only option that works now is by sending the field picture with the url to a 1x1 pixel image.
Related
I've spent a lot of time trying to send a game request from the (latest) JS API, using the Graph API v2.8, but nothing seems to work.
I've used only common OG, since custom OG are deprecated. When I use "turn" instead of "send" as the action type, my request works, since the "turn" requests don't require an object id, so I guess the problem comes from my OG.
I first created an action like this:
curl -X POST \
-F "access_token=*a user access token*" \
-F "game=*my game id*" \
https://graph.facebook.com/v2.8/me/games.plays
And then sent a game request using it the returned id in the "object_id" field. And this is the result I got:
Facebook response after calling FB.ui
Which doesn't provide any information...
So I tried to make a game object instead of an action. I figured "maybe you can't use actions in this context", and since game.achievement is the ONLY game object available, I made an achievement object, like this:
curl -X POST \
-F "access_token=*my app access token*" \
-F "object={\"fb:app_id\":\"*my app id*\",\"og:type\":\"game.achievement\",\"og:url\":\"*object's URL*\",\"og:title\":\"*A title*\",\"og:description\":\"*A description*\",\"og:image\":\"*A link to an image*\",\"game:points\":\"1\"}" \
https://graph.facebook.com/v2.8/app/objects/game.achievement
This is the result that I got:
Facebook response after calling FB.ui
Which makes no sense, because the object was created using an app access token, and that my app IS a game. So this statement makes no sense.
And now, I'm lost. I have no solution left, no new idea to try. I don't know what to do... The documentation is obviously missing information. They didn't even bother making a documentation for the games.plays action...
I need someone who knows how to use this damned API to help me figure this out, because right now, I'm just completely stuck.
Thanks in advance, community.
I'm attempting to have multiple title and descriptions for a same endpoint, one per language.
Trying to follow this documentation: https://developers.facebook.com/docs/opengraph/guides/internationalization#objects
I have a server that detects when the client is a bot, for example facebook bot, and it renders a single file with the title and description metas, and the following localization metas. I have a file for each language, and I set og:locale depending on the localization fb_locale that I recieve on the queryparams.
meta(property="og:locale" content="en_gb")
meta(property="og:locale:alternate" content="es_es")
meta(property="og:locale:alternate" content="it_it")
How can I have multiple language for the same endpoint?
This is my testing app and endpoint I'm trying to translate: https://webapp-server-21b.herokuapp.com/marcp
It seems that it crawls it properly, but does not display the preview in the language I expect when I share it on FB or in the debugger of facebook.
If I perform :
curl -X POST -F "id=https://webapp-server-21b.herokuapp.com/marcp" -F "scrape=true" -F "locale=en_gb" "https://graph.facebook.com" -s
or:
curl -X POST -F "id=https://webapp-server-21b.herokuapp.com/marcp" -F "scrape=true" -F "locale=es_es" "https://graph.facebook.com" -s
I get the expected title in the corresponding expected language, but when I share on facebook or in the debugger it's always in english, the default locale.
Thanks!
I am trying to post an action using Facebook Open Graph API based on the Facebook documentation. When I do the following :
curl -X POST \
"https://graph.facebook.com/app/myNamespace:myAction" \
-F "access_token=$APP_TOKEN" \
-F "myObject=https://myhost.com/objectid"
I get the following error :
{"error":{"message":"(#200) Requires extended permission: publish_actions","type":"OAuthException","code":200}}
I have obtained a valid 'App Token' using this Faceboo documentation. The document states that actions can be published using App Tokens.
Btw, I am able to successfully post actions using user-access-token as follows :
curl -X POST \
'https://graph.facebook.com/me/myNamespace:myAction' \
-F 'myObject=https://myhost.com/' \
-F 'access_token=user-access-token'
Any Help is greatly appreciated.
You're trying to post to an Open Graph action as the app, which is not possible.
Unfortunately, there is no documentation to that explictly says this, but here is someone who tried to do the same thing.
If you read the documentation you posted, you'll see two main points. First, app tokens are for publishing information on the feeds of user's who have given permission to the app to do so, and app tokens are for some other basic "maintenance" type stuff for the app itself. There is nothing in there that support the idea that app tokens can be used for anything like posting regular Open Graph actions.
I'm very new to Facebook (yeah, I'm the only one) but I'd like to publish messages in the wall programmatically using Python.
What do I need to do to achieve that? I'm very confused. I have seen that most question about this are focused on how to let an app interact in some way with Facebook, but I'd like to post as if I were a simple user (a user which happens to "own" that particular Facebook page). Do I really need to go and create an app? (By the way, I'm having problems even with that... it tells me that my account seems fake or invalid even after I validated it via SMS). I imagine that there is a simpler way, introducing my credentials, using a POST request but I haven't read something similar.
I would have thought this is what I needed, but it leads to a page to create an app.
Some pointers?
By the way, I got a token via a publish_stream permission in the Graph API Explorer (using the extended permissions tab). Seems like this permission doesn't have expiration date but it's not recommended. Is there a better choice for a token?.
Thanks
Facebook is a bit trickier than other sites it would appear.
While watching the POST tab under NET in Firebug, while logging in, I see the following POST parameters:
charset_test €,´,€,´,水,Д,Є
default_persistent 1
email myusername
lgnjs 1340241652
lgnrnd 182050_CuPx
locale en_US
lsd AVqwALVx
pass mypassword
persistent 1
timezone 240
I don't yet know what lsd paramater is, but I did find out what the lgnrnd was by viewing the source of the login page before I logged in. It appears to be there to make it more difficult to automate authentication.
You first want your script to scrape that login page for that value, store it in a variable. Then, a cURL example would be something like:
curl -L "https://www.facebook.com/login.php?login_attempt=1" \
--cookie-jar /tmp/cookies.txt \
--data-urlencode "email=myusername" \
--data-urlencode "lgnrnd=$lgnrnd" \
--data-urlencode "pass=mypassword"
and so forth, with all the parameters...
This is untested of course, and I don't know what some of those parameter values are yet, but you should get the idea from that. You could probably use a python module like Beautiful Soup or something to apply the above basic concept.
Then you would do the same thing, watching the NET tab to find the parameters sent when you post to your facebook wall, and put it all together.
Note that I'm storing and using cookies with curl's --cookie-jar option. You will need a way to save and use cookies with the request as well, which is why I showed that.
Hope that helps you get started anyway..
What about this?.
import urllib2, urllib
parameters = {}
parameters['access_token'] = MY_TOKEN
parameters['message'] = 'Hello world'
target = 'https://graph.facebook.com/MY_ID/feed'
parameters = urllib.urlencode(parameters)
handler = urllib2.urlopen(target, parameters)
while True:
if handler.code < 400:
print handler.read() # Gets post_id
break
elif handler.code >= 400:
print 'Error' # :-(
break
Are there problems with this? Maybe a better way? Comments?
Thanks
Picture posting NOT working with Facebook Graph API
The message is posted but the picture is NOT.
I am using the Graph API to post to the wall on Facebook.
My code was working fine posting the picture but is NOT posting picture anymore!
Here are the CURL parameters:
I am posting to URL: https://graph.facebook.com/ID/feed
and the POST parameters are:
access_token=TheToken&message=My+Message&picture=ImgUrl
where:
access_token is a valid access token
message is the message to display on the wall
picture is the image associated with the message to display on the wall
The ID is valid and access_token is valid.
Any help is appreciated, Facebook seems to be notorious in changing their API without informing interfacing sites!
I had the same problem when posting using the graph api via PHP. Dont know what the cause what, but my image URLs contained a - sign (http://the.url/to/the-image.jpg).
After renaming the images, everything worked as expected.
What is your image url?
I used the LINK parameter instead of the PICTURE parameter and all seems to be working now. Facebook changed something in regards to the PICTURE parameter where it stopped working. I did NOT change any code on my system and it just stopped working. See http://developers.facebook.com/docs/reference/api/post/
Ken, but what if you want link= to point to something else? this works:
curl -F \
"picture=http://tycho.usno.navy.mil/gif/moons/m146.gif" \
-F "message=you're looking great tonight!" \
-F "name=Current Moon Phase" \
-F "link=http://www.calculatorcat.com/moon_phases/phasenow.php" -F caption="How the moon appears tonight" \
-F "access_token=111111111111111|2222222222222222222222222|33333333333333333333456n" \
"https://graph.facebook.com/215958041750734/feed"
you can see result at: https://www.facebook.com/pages/The-Moon/215958041750734
works for me using source parameter:
$graph_url= "https://graph.facebook.com/me/feed?"
. "source=" . urlencode($_POST["picture"])
. "&link=" . urlencode($_POST["link"])
. "&message=" . urlencode($_POST['message'])
. "&method=POST"
. "&access_token=" .$access_token;
$response=file_get_contents($graph_url);
$json=json_decode($response);
Posting picture works for me but somehow including a source (swf) causes the picture to not display anymore. This used to work until last week.
Wait for it
I noticed that it takes more time for Facebook to process the picture (up to 15 minutes) than to post the link on the timeline (instant).