Facebook cURL posting as me?

前端 未结 1 1155
耶瑟儿~
耶瑟儿~ 2021-01-24 12:08

Create facebook app

Using a cURL to post a message from an App but it\'s appearing to be posted from me? How can I can it to post from the app, here\'s my cURL



        
1条回答
  •  醉话见心
    2021-01-24 12:38

    Here is the code it works for me

    $file = 'image.jpg';
    $args = array(
       'message' => 'Photo from application',
        'access_token'=>urlencode('Your Access token'),
    );
    $args[basename($file)] = '@'.realpath($file);
    
    $ch = curl_init();
    $url = 'https://graph.facebook.com/me/photos';
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
    $result = curl_exec($ch);
    curl_close ($ch);
    

    May be it helps you.

    0 讨论(0)
提交回复
热议问题