Facebook graph API & PHP SDK questions

无人久伴 提交于 2019-11-29 05:21:54

Concerning your 2nd problem, I remember reading somewhere about a DELETE request, instead of POST. See: http://developers.facebook.com/docs/api#deleting

Read the documentation

curl -F 'access_token=...' \
     -F 'source=@file.png' \
     -F 'message=Caption for the photo' \
     https://graph.facebook.com/me/photos

See how the source parameter is formatted?

$fb_foto = $fb->api('me/photos','POST',array(
    'access_token' => (...)
  , 'message'      => 'Caption'
  , 'source'       => '@' . realpath( 'path/to/file' )
));

To delete photos, again the documentation has your answer: Issue a DELETE request

$fb->api( '/PHOTO_ID', 'DELETE' );

I'm using this method with the new php-sdk (v2.1.1, facebook-php-sdk-v2.1.1-0-g08909f3.zip) to upload a photo for a new event. The php code below creates the event.

$fname="/tmp/foo.jpg";
$attachment =  array(
        'access_token' => $facebook->getAccessToken(),
        'name' => substr(event_name),
        'description' => my_description,
        'start_time' => my_start_time,
        'link' => my_link,
        'source'=> '@'.$fname
        );
$result = $facebook->api('/me/events', 'POST', $attachment);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!