How to upload image to existing fan page if the user is not the administrator fan page?

105 views Asked by At

This code return "invalid album id". if the user is admin fan page then it works. But I need that all users can upload photos through the app in fan page album.

$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;
0

There are 0 answers