Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用php curl自动共享链接_Php_Facebook Graph Api - Fatal编程技术网

使用php curl自动共享链接

使用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

我想使用以下脚本在我的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 } } 
如何修复链接

创造

您可以使用
发布流
权限向PROFILE\u ID/feed发出HTTP post请求,代表用户发布链接

其他字段取自“link”参数中给出的页面URL的元数据

如果创建成功,您将获得以下返回

参考:

curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/me/feed');