下面的代码会发布到相册,但也会在主时间轴中发布。有没有办法只发布到专辑。
<?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'];
?>
答案 0 :(得分:0)
修改:自2017年1月起无效。 More info here...
这是一个老帖子,我搜索了一个不同的主题,但如果我在这里......
$data = [
'message' => 'My awesome photo upload example.',
'source' => $fb->fileToUpload('./img/sandy.jpg'),
'published' => false,
];