使用php curl自动共享链接
我想使用以下脚本在我的facebook墙上自动共享链接:使用php curl自动共享链接,php,facebook-graph-api,Php,Facebook Graph Api,我想使用以下脚本在我的facebook墙上自动共享链接: $attachment = array( 'email' => 'mail', 'password' => 'password', 'access_token' => 'my token', 'message' => "my message", 'name' => 'name', 'link' => 'my_url', 'descripti
$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 } }
如何修复链接
创造
您可以使用发布流
权限向PROFILE\u ID/feed发出HTTP post请求,代表用户发布链接
其他字段取自“link”参数中给出的页面URL的元数据
如果创建成功,您将获得以下返回
参考:
curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/me/feed');