图像不能在FB.ui中工作(Images not working in FB.ui)

编程入门 行业动态 更新时间:2024-10-26 12:21:47
图像不能在FB.ui中工作(Images not working in FB.ui)

尝试发布图像以及墙贴可以使用以下代码正常工作几个月。 突然它停止工作。

当我用https测试它时,它不起作用,但在http中它起作用。

如果协议是https,则APP URL使用https,否则使用http。

$protocol = "http"; if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']!="off") $protocol = "https"; define("CANVAS_URL","$protocol://apps.facebook.com/appname/"); define("APP_URL","$protocol://domain.com/content/appname/live/"); FB.ui( { method: 'feed', name: 'my app name', link: <? echo "'".CANVAS_URL."'";?>, picture: <? echo "'".APP_URL."'";?>+image, caption: _caption, description: _description }, function(response) { if (response && response.post_id) { // published } else { // not published } } );

Trying to post an image along with wall post was working fine for couple of months with the following code. Suddenly it stopped working.

When I test it with https it doesn't work but in http it works.

The APP URL is using https if the protocol is https and http otherwise.

$protocol = "http"; if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']!="off") $protocol = "https"; define("CANVAS_URL","$protocol://apps.facebook.com/appname/"); define("APP_URL","$protocol://domain.com/content/appname/live/"); FB.ui( { method: 'feed', name: 'my app name', link: <? echo "'".CANVAS_URL."'";?>, picture: <? echo "'".APP_URL."'";?>+image, caption: _caption, description: _description }, function(response) { if (response && response.post_id) { // published } else { // not published } } );

最满意答案

尽量不要使用SSL URL来获取图像(但仍将其用于链接的CANVAS_URL)。 Facebook代理向用户展示的图片请求,因此即使您从非SSL网址提供图片,Facebook中使用的图片也会通过SSL与用户展示。

至于SSL网址无效的原因,可能是由Facebook使用的抓取工具检索图像无法识别您正在使用的证书链。 你在浏览器中对我的工作很好,但是当通过Linux命令行上的wget进行检索时(可能与浏览器相比FB的搜索器更接近环境),则无法验证证书。

Try not using an SSL URL to get the image (but still using it for your linked CANVAS_URL). Facebook proxies the image requests it shows to users, so even if you're serving it from a non-SSL URL, the image used within Facebook will reach users over SSL.

As to why the SSL URL isn't working, it could be that the crawler used by Facebook to retrieve the image doesn't recognize the certificate chain you're using. Yours worked fine for me in a browser, but when retrieving via wget on a Linux command line (likely a closer environment to FB's crawler than a browser is), there's a failure to verify the certificate.

更多推荐

本文发布于:2023-08-08 01:11:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1466767.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:能在   图像   工作   ui   FB

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!