Reputation: 79
Photo not uploaded in facebook album after giving enough file upload permission.... i have also refered related question for graph api still there is no success...
$facebook->getLoginUrl(array('scope' => 'user_status,publish_stream,user_photos,photo_upload,can_upload'));
$album_details = array(
'message'=> 'Testing Description For Pic',
'name'=> 'Testing Pic Album'
);
$create_album = $facebook->api('/me/albums', 'post', $album_details);
$args = array(
'message' => 'Photo from application',
'image' => '@'.$imgURL
);
$url = 'http://graph.facebook.com/'.$create_album['id'].'/photos?access_token='.$aut_key;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
$data = curl_exec($ch);
Upvotes: 1
Views: 2407
Reputation: 8084
Here is the code it works for me
<?php
$img = 'image.jpg';
$args = array(
'message' => 'Photo from application',
'access_token'=>urlencode('Your Access token'),
);
$args[basename($img)] = '@'.realpath($img);
$ch = curl_init();
$url = 'https://graph.facebook.com/me/photos';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
$data = curl_exec($ch);
$response = json_decode($data,true);
if($response[id]>0){
// yes
}
print_r(json_decode($data,true));
print_r(curl_error($ch));
?>
May be it helps you.
Upvotes: 1
Reputation: 1054
Try changing
'image' => '@'.$imgURL
to
'source' => '@'.$imgURL
The Facebook API specifes that "source" should contain the image information. There is no mention in the image API of a "image" field when uploading images.
Upvotes: 0
Reputation: 1240
I had faced the same problem,
Please try to make sure that $imgURL is the relative image location on your server and not a generic web url of the image.
Also, try to crosscheck here http://developers.facebook.com/blog/post/498/
Upvotes: 0