I am developing an app to include in my page tab. In this app, the user will go take a picture with your webcam and the picture will sent to an especific album in my fan page.
I found an script here: and he is working very well, but I've a problem, the script use an user access_token to upload the picture, dont's necessary ask permission of all users to upload the picture because the script use my administrator user to send to the page.
The big problem is: The user access token expire after 2 hours or when my admin user not logged in, the permission offline_access was discontinued and I don't know how my script will work.
I need that all user can upload photo using the system, anyone know how I can work?
Here is the script in PHP:
`
require_once 'library/facebook.php';
$facebook = new Facebook(array(
'appId' => '<appid>',
'secret' => '<appsecret>',
'fileUpload' => true
));
$access_token = 'access_token';
$params = array('access_token' => $access_token);
$fanpage = 'page_id';
$album_id ='album_id';
$accounts = $facebook->api('/ADMIN_ACCOUNT/accounts', 'GET', $params);
foreach($accounts['data'] as $account) {
if( $account['id'] == $fanpage || $account['name'] == $fanpage ){
$fanpage_token = $account['access_token'];
}
}
$valid_files = array('image/jpeg', 'image/png', 'image/gif');
$img = realpath("image_path");
$args = array(
'message' => 'message to write in legend',
'image' => '@' . $img,
'aid' => $album_id,
'no_story' => 1,
'access_token' => $fanpage_token
);
$photo = $facebook->api($album_id . '/photos', 'post', $args);
if( is_array( $photo ) && !empty( $photo['id'] ) ){
echo '<p><a target="_blank" href="http://www.facebook.com/photo.php?fbid='.$photo['id'].'">Click here to watch this photo on Facebook.</a></p>';
}`