此代码返回“无效的专辑ID”。 如果用户是管理员粉丝页面,那么它的工作原理。 但我需要所有用户都可以通过粉丝专辑中的应用上传照片。
$config = array(
'appId' => '553412241404428',
'secret' => '...',
'fileUpload' => true, // optional
'allowSignedRequest' => false, // optional, but should be set to false for non-canvas apps
'cookie' => true
);
// exist ALBUM from URL
$ALBUM_ID = "765349256813004";
$filename = $_GET['file'];
$facebook = new Facebook($config);
$facebook->setFileUploadSupport(true);
if(!$user = $facebook->getUser()) {
echo "<a target='_blank' href='".$facebook->getLoginUrl(array('scope' => 'publish_actions,publish_stream,user_photos,email,read_stream,manage_pages,user_groups'))."'>Auth</a>";
exit;
}
$access_token = $facebook->getAccessToken();
$FILE_PATH = $_SERVER['DOCUMENT_ROOT']."facebook/uploads/".$filename;
$args = array('message' => 'Photo Caption');
$args['image'] = '@' . realpath($FILE_PATH);
$args['access_token'] = $access_token;
$data = $facebook->api('/'. $ALBUM_ID . '/photos', 'post', $args);
print_r($data);exit;