how to post image from website to facebook

i want to upload image to facebook album using facebook api, i search alot about it if find out that the file used is from the pc.. i want to upload image to facebook album and the image path i want to get from a website ?

$args = array('message' => 'Photo Caption');
$args['image'] = '@' . realpath($FILE_PATH);

$data = $facebook->api('/'. $ALBUM_ID . '/photos', 'post', $args);

is that possible to give a file path like i mention above?


You have couple of severe mistakes in your code:

  1. $File_path isn't the same as $FILE_PATH - remember variables are case sensitive!
  2. realpath accepts path not URL and will return false in your case

You can only upload local files using image parameter, and for remote images url parameter should be used.

Consider using one of the next samples to achieve the desired result, for local file:

$facebook->api("/{$ALBUM_ID}/photos", "post", array(
  'message' => 'Photo caption',
  'image'   => '@'.realpath('./path/to/local/image/file.jpg')

And for remote file:

$facebook->api("/{$ALBUM_ID}/photos", "post", array(
  'message' => 'Photo caption',
  'url'   => ''

Need Your Help

How to use variables in PostgreSQL in Python

python postgresql psycopg2

My Sounds table has 7 columns: Start_Time, End_Time, Salience_Label, Class_label, Bitrate, Bitdepth, Samplerate.