Diogo Mendonça
Diogo Mendonça

Reputation: 913

Php Facebook - Upload Image from External Source

Good morning fellows, I am having an issue with facebook api: is it possible to upload a photo from an external source? For instance, point out an URL and the Facebook will get that... My code is right next

$args = array( 'message' => 'Photo from application', 'source' => $im_url );
$url = 'https://graph.facebook.com/'.$album_id.'/photos?access_token='.$token;
$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);

the $im_url should point out to an external picture, like store on imageshack,etc.
The error it gives me is {"error":{"message":"(#324) Requires upload file","type":"OAuthException"}}

Upvotes: 1

Views: 1754

Answers (1)

Diogo Mendonça
Diogo Mendonça

Reputation: 913

Instead of "source", the term is "url". Problem solved $args = array( 'message' => 'Photo from application', 'url' => $im_url

Upvotes: 4

Related Questions