I am trying to upload a photo to user's album with current script:
$this->facebook->api('/me/photos?access_token='.$user->access_token, 'post', $args);
$user->access_token is the user's access token and I check via Facebook Graph API Explorer tool it says still valid (until 2 months).
However if I create API request with script above, my console always returned:
Fatal error: Uncaught OAuthException: An active access token must be used to query information about the current user.
What I've been doing is:
- deauthorize app
- re-authorize app
- request permission (publish_stream,photo_upload,user_photos)
- update FB SDK to latest version
Here is the full code:
$user = $this->User_model->get_access_token($this->input->post('fb_id'));
foreach($this->input->post('media') as $media_id)
{
$media = $this->Media_model->get_media($media_id);
$args = array('message' => 'Photo Caption');
$args['image'] = '@' . realpath(FCPATH.'uploads/booth_1/'.$media->file);
$data = $this->facebook->api('/me/photos?access_token='.$user->access_token, 'post', $args);
print_r($data);
}
Any help?
FYI I am using codeigniter. And actually I was trying hours ago (it worked), however, now is not, because of access_token.
Thanks.