简体   繁体   English

如何在没有缩略图的情况下发布链接到Facebook?

[英]How do I post a Link to Facebook without a thumbnail?

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. 我想使用Graph API发布一个链接到Facebook,但我希望能够避免缩略图。 Facebook's web interface has a no-thumbail checkbox while posting an image; Facebook的网络界面在发布图像时没有任何缩略图复选框; 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. 我已经尝试为sourcepicture参数指定一个空字符串,但Facebook仍然为指定的link提取缩略图图像。

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. 更新: 此支持论坛表明这是Facebook的一个错误,他们建议发布一个1x1像素的清晰图像。 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. 由于picture=0似乎不再没有抛出错误,所以这是另一种方式,但这是一个黑客,不太可能推荐。 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. 通过跳过picture参数并指定作为有效URL但不是图像的source参数,Facebook将呈现没有缩略图的帖子。 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 . 现在Facebook已经修正了这个错误 Set picture to empty string or set picture=NULL, both should work now. 将图片设置为空字符串或设置图片= NULL,两者都应该工作。

I talked with Facebook developers at F8 2011 and they agreed that this is a bug. 我在F8 2011与Facebook开发人员交谈,他们一致认为这是一个错误。 I have filed this bug with Facebook in their new bug tracking system: 我已经在他们的新错误跟踪系统中向Facebook提交了这个错误:

https://developers.facebook.com/bugs/231434760243248 https://developers.facebook.com/bugs/231434760243248

If you want it fixed, upvote this question & answer! 如果你想修复它,请提出这个问题和答案!

Try using the value "0" for picture. 尝试使用值“0”作为图片。 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. 这对我们有效,它确实在链接信息旁边显示一个灰色条,但它不会拉入默认图像,并且在使用1x1像素时不会显示尴尬的空白。

Hope this helps! 希望这可以帮助!

put an invalid url image it's will "resolve" while the facebook not fix this bug. 放一个无效的网址图像,它将“解决”,而Facebook没有修复此错误。 the parameter is: "picture" 参数是:“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. 这已被Facebook禁用,这不是一个错误,它是由FB团队在这里设计的。 They say they will remove the "No thumbnail" option from their site too, not just on the API. 他们说他们也会从他们的网站上删除“没有缩略图”选项,而不仅仅是在API上。 The thread I linked is the most recent (31 Dec 2015). 我链接的主题是最新的(2015年12月31日)。

The only option that works now is by sending the field picture with the url to a 1x1 pixel image. 现在唯一可行的选择是将带有网址的字段picture发送到1x1像素图像。

Now in June 2011 it seems the "picture=" parameter isn't required at all, and FB didn't pull one from the page either: 现在在2011年6月,似乎根本不需要“picture =”参数,FB也没有从页面中拉出一个:

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 结果在SO的Facebook页面: 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. 然而,对于完全公开,我没有在生产中使用这个解决方案因为它看起来很hacky而且我不相信Facebook允许这种方法无限期地存在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM