image - Facebook api posting to an Album -
the code below posts photo album posts in main timeline. there way post album.
<?php require_once __dir__ . '/vendor/autoload.php'; $fb = new facebook\facebook([ 'app_id' => 'xxxxxxxx', 'app_secret' => 'xxxxxxxxx', 'default_graph_version' => 'v2.5', //'default_access_token' => '{access-token}', // optional ]); $data = [ 'message' => 'my awesome photo upload example.', 'source' => $fb->filetoupload('./img/sandy.jpg'), ]; try { // returns `facebook\facebookresponse` object $response = $fb->post('/me/photos/test', $data, '{token}'); } catch(facebook\exceptions\facebookresponseexception $e) { echo 'graph returned error: ' . $e->getmessage(); exit; } catch(facebook\exceptions\facebooksdkexception $e) { echo 'facebook sdk returned error: ' . $e->getmessage(); exit; } $graphnode = $response->getgraphnode(); echo 'photo id: ' . $graphnode['id']; ?>
edit: not working january of 2017. more info here...
it's old post, , i've searched different topic, if i'm here...
$data = [ 'message' => 'my awesome photo upload example.', 'source' => $fb->filetoupload('./img/sandy.jpg'), 'published' => false, ];
Comments
Post a Comment