尝试发布图像以及墙贴可以使用以下代码正常工作几个月。 突然它停止工作。
当我用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.
更多推荐
发布评论