为什么“喜欢"按钮不能立即起作用? [英] Why doesn't Like button work immediately?

查看:73
本文介绍了为什么“喜欢"按钮不能立即起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用喜欢"按钮创建一个新网页并首次访问该页面时,该按钮不显示og:title或og:description数据或我指定的og:image.我必须先通过 https://developers.facebook.com上的Facebook调试器运行它来手动抓取该页面. /tools/debug .

When I create a new web page with a Like button and access the page for the first time, the button doesn't show the og:title or og:description data, or the og:image that I've specified. I have to scrape the page manually first by running it through the Facebook debugger at https://developers.facebook.com/tools/debug.

我的理解是,Facebook每隔24小时会自动抓取一次该页面,如果您希望更快地显示更改,则必须通过调试器运行它来自己进行抓取.但是,当您第一次在页面上单击赞"按钮时,Facebook是否不会刮刮一次页面,所以我不必第一次刮刮页面吗?

My understanding is that Facebook scrapes the page every 24 hours automatically and if you want changes to show up sooner you have to scrape it yourself by running it through the debugger. But doesn't Facebook scrape the page once the first time you call the Like button on it, so I shouldn't have to scrape it the first time?

我应该提到,通过调用

https://developers.facebook.com/docs/plugins/like-button

相反,由我开发的网站构建器正在生成获取赞"按钮的网页.当用户选择一个喜欢"按钮图标放在页面上时,将修补以前生成的按钮中的代码,以包含新的网站名称,等等.

Instead, the web page that gets the Like button is being generated by a site builder that I developed. When the user selects a Like button icon to put on the page, code from a previously generated button is patched to contain the new site name, etc.

此外,如果需要的话,它也是XFMBL按钮.

Also, it's an XFMBL button, if that matters.

我想,我所希望的最佳解决方案是一种从PHP编程调用Facebook调试器的方法,其中URL会刮入查询字符串,而调试器将在不打开任何类型的字符串的情况下做到这一点.用户对话框.

The best solution I could hope for, I guess, would be a way to call the Facebook debugger programatically from PHP with the URL to scrape in the query string, and the debugger would just do it without opening up any kind of a user dialog.

感谢任何想法.

推荐答案

在生成赞"按钮时,可以使用以下代码将其发送给调试器:

You can use this code to send it to the debbugger when you generate the like button:

$curlUrl = 'https://developers.facebook.com/tools/debug/og/object?q=' .
    urlencode(your like link);
$access_token = FACEBOOK_APP_ID | FACEBOOK_APP_SECRET;
$params = array(
    'id'           => $curlUrl,
    'scrape'       => 'true',
    'access_token' => $access_token
);
$ch = curl_init('https://graph.facebook.com');
curl_setopt_array($ch, array(
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_SSL_VERIFYHOST => false,
    CURLOPT_SSL_VERIFYPEER => false,
    CURLOPT_POST           => true,
    CURLOPT_POSTFIELDS     => $params
));
$result = curl_exec($ch);

这篇关于为什么“喜欢"按钮不能立即起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆