アクションをタイムラインに公開するために、このスキームを使用しています。
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...
Open Graph アクションを PHP で公開するにはどうすればよいですか?