我正在使用此方案将我的操作发布到时间线:
function postCook()
{
FB.api(
'/me/app_url:action',
'post',
{ object: 'url address' },
function(response) {
if (!response || response.error) {
console.log(response);
alert('Error occured');
} else {
alert('Cook was successful! Action ID: ' + response.id);
}
});
}
<input type="button" value="Cook" onclick="postCook()" />
如何将这个 JS 函数重写为 PHP?我尝试过这样的事情(我在这里找到的):
$myurl = 'https://graph.facebook.com/me/url_app_name:action?object=url_address&access_token=ACCESS_TOKEN&method=post';
$result = file_get_contents($myurl);
但这返回了我的错误
Warning: file_get_contents(content of $myurl) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request in...
如何在 PHP 中发布 Open Graph 操作?