我想使用以下脚本自动共享我的facebook墙中的链接:
$attachment = array(
'email' => 'mail',
'password' => 'password',
'access_token' => 'my token',
'message' => "my message",
'name' => 'name',
'link' => 'my_url',
'description' => "my description"
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/me/links');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,5);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.001 (windows; U; NT4.0; en-US; rv:1.0) Gecko/25250101');
curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$json = json_decode($result);
$post_id = $json->{'id'};
curl_close($ch);
一开始它对我有效,但在尝试了7次或更多次后,我出现了这个错误:
{ "error": { "message": "(#100) The parameter url is required", "type": "OAuthException", "code": 100 } }
如何修复
链接
创建
您可以通过向具有publish_stream
权限的PROFILE_ID/feed发出HTTP post请求,代表用户发布链接。
其他字段取自"link"参数中给定的页面URL的元数据。
如果创建成功,则会得到以下返回。
请参阅:https://developers.facebook.com/docs/reference/api/user/#links
curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/me/feed');