简体   繁体   English

图像在FB.ui中不起作用

[英]Images not working in FB.ui

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. 当我使用https进行测试时,它不起作用,但在http中可行。

The APP URL is using https if the protocol is https and http otherwise. 如果协议是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
         }
       }
    );

Try not using an SSL URL to get the image (but still using it for your linked CANVAS_URL). 尽量不要使用SSL URL来获取图像(但仍然将其用于链接的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. Facebook代理它向用户显示的图像请求,因此即使您从非SSL URL提供图像,Facebook中使用的图像也将通过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. 至于为什么SSL URL不起作用,可能是Facebook用来检索图像的爬虫无法识别您正在使用的证书链。 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. 你在浏览器中为我工作得很好,但是当在Linux命令行上通过wget检索时(可能是比FB浏览器更接近浏览器的环境),无法验证证书。

One thing I just discovered, the image size seems to also play a role. 我刚发现的一件事,图像大小似乎也发挥了作用。 My picture URL was to the original full size jpg. 我的图片网址是原始的全尺寸jpg。 And it didn't show. 它没有表现出来。 But after I linked to a much smaller sized version, then it showed! 但在我链接到一个小得多的版本后,它显示了!

I had the same 'thin grey bar' as Black Knight on two of the four feed posts on my page. 在我页面上的四个饲料柱中的两个上,我和Black Knight一样有“薄灰条”。
I took out the https:// and now the all work fine... 我拿出了https://现在一切正常......

was... 是...
picture: 'https://mysite.com/images/' + image, 图片:'https://mysite.com/images/'+图片,
now... 现在...
picture: 'mysite.com/images/' + image, 图片:'mysite.com/images/'+图片,

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

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