aabu0...@gmail.com
unread,May 9, 2013, 11:12:47 PM5/9/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to koala...@googlegroups.com
//html form for uploading the image
<form enctype="multipart/form-data" action="upload.php" method="POST">
Please choose a photo:
<input name="photo" type="file"><br/><br/>
Say something about this photo:
<input name="message" type="text" value=""><br/><br/>
<input type="submit" value="Upload"/><br/>
</form>
//html form will be redirecting to upload.php
//this is upload.php file ..
<?php
//upload.php
if(isset($_FILES['photo']) && isset($_POST['message'])){
$uploadfile ='./uploads/'.basename($_FILES['photo']['name']);
$iStats=getimagesize($_FILES['photo']['tmp_name']);
if (isset($iStats['mime']) && $iStats[0]>0) {
move_uploaded_file($_FILES['photo']['tmp_name'], $uploadfile);
require_once('sdk/src/facebook.php');
require_once('utils.php');
require_once('AppInfo.php');
try{
//this one is used to find the APPID and secret of the app
$facebook = new Facebook(array(
'appId' => AppInfo::appID(),
'secret' => AppInfo::appSecret(),
'sharedSession' => true,
'trustForwarded' => true,
));
$album_details = array(
'message'=> 'Album desc',
'name'=> 'Album name'
);
$uid = $facebook->getUser(); //used to get the user id
$me = $facebook->api('/me');
$token = $facebook->getAccessToken(); //here I get the token from the $session array
$create_album = $facebook->api('/me/albums', 'post', $album_details);
$album_id = $create_album['id'];
$facebook->setFileUploadSupport(true);
$args['image'] = '@' . realpath($uploadfile);
$data = $facebook->api('/'. $album_id . '/photos?access_token='. $token, 'post', $args['image']);
// $data = $facebook->api('/'.$album_id.'/photos', 'post', $args['image']);
} catch(FacebookApiException $e){
echo "Error:" .$e;
}
unlink($uploadfile);
echo "Success!\n";
} else {
echo "Wrong file type!\n";
}
}
?>