I have developed an app so that users can upload images to a page's album. I do not want users to have to authorize and so I used the access token from the app to upload the images for them. This works fine if the admin is logged in and the access token hasn't expired - it only seems to last for a couple hours. I have looked through stackoverflow and facebook and tried many different things and nothing seems to work. Here is some of the code I am using:
try {
$facebook->setAccessToken("APP_ACCESS_TOKEN_FROM_GRAPH_API_TOOL");
$token_url="https://graph.facebook.com/oauth/access_token?client_id=APP_ID&client_secret=APP_SECRET&grant_type=fb_exchange_token&fb_exchange_token=".$facebook->getAccessToken();
$page_id = 'PAGE_ID';
$response = file_get_contents($token_url);
$params = null;
parse_str($response, $params);
$page_info['access_token'] = $params['access_token'];
$page_info = $facebook->api("/".$page_id."?fields=access_token");
if( !empty($page_info['access_token']) ) {
$photo_details['access_token'] = $page_info['access_token'];
$upload_photo = $facebook->api('/'.$page_id.'/photos', 'post', $photo_details);
Am I dreaming? Is this possible and I just screwed up the code? Any help would be much appreciated even just to point me in the right direction...