How do I post a Link to Facebook without a thumbna

2020-07-06 04:29发布

问题:

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.

回答1:

Facebook has now fixed this bug. Set picture to empty string or set picture=NULL, both should work now.



回答2:

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


回答3:

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!



回答4:

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!



回答5:

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



回答6:

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.



回答7:

put an invalid url image it's will "resolve" while the facebook not fix this bug. the parameter is: "picture"



回答8:

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.