简体   繁体   中英

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.

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
         }
       }
    );

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.

One thing I just discovered, the image size seems to also play a role. My picture URL was to the original full size 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.
I took out the https:// and now the all work fine...

was...
picture: 'https://mysite.com/images/' + image,
now...
picture: 'mysite.com/images/' + image,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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