Reputation: 2346
I am using this code to upload photos to existing album with access_token
$FILE_PATH='C:\\wamp\\www\\photo\\photo.jpg';
$args = array('message' => 'Photo Caption');
$args['image'] = '@' . realpath($FILE_PATH);
$data = $facebook->api('/'. $aid . '/photos?access_token='. $user_access_token, 'post', $args);
print_r($data);
I have a valid access_token with publish_stream permission. I have checked i have a valid access_token, but here is an error comming.
> Fatal error: Uncaught OAuthException: An access token is required to request this resource. thrown in C:\wamp\www\photo\facebook-php-sdk\src\base_facebook.php on line 970
Upvotes: 0
Views: 986
Reputation: 2346
The problem is that we need to set the access-token in the args,and then call to upload album, this was a fix that applied and it worked. thanks for your comments and answer,
Upvotes: 1
Reputation: 16091
You need to set the upload support to true. The following code works for me:
$facebook->setFileUploadSupport(true);
$facebook->api('/'.$aid.'/photos', 'POST', array('image'=> '@' . realpath($FILE_PATH), 'message'=> 'Photo Caption'));
and furthermore, you will probably need the user_photos
, photo_upload
, and the publish_stream
permissions.
Upvotes: 1