2

このスクリプトを使用して、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 } } 

どうすれば修正できますか

4

1 に答える 1

1

リンク

作成

アクセス許可を持つPROFILE_ID/feedに HTTP POST リクエストを発行することで、ユーザーに代わってリンクを投稿できます。publish_stream

他のフィールドは、「リンク」パラメーターで指定されたページ URL のメタデータから取得されます。

作成が成功すると、次のリターンが返されます。

参照: https://developers.facebook.com/docs/reference/api/user/#links

curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/me/feed');
于 2013-02-11T02:49:42.600 に答える