0
下面的代碼發佈到相冊中,但也發佈在主時間軸上。有沒有辦法只發布到相冊。Facebook api發佈到相冊
<?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 a `Facebook\FacebookResponse` object
$response = $fb->post('/me/photos/test', $data, '{token}');
} catch(Facebook\Exceptions\FacebookResponseException $e) {
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
$graphNode = $response->getGraphNode();
echo 'Photo ID: ' . $graphNode['id'];
?>