Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is possible, but requires an intermediate step (as @jlb mentions) of storing a local copy. You simply need the URL(s) for the image(s) you want to pull and appropriate permissions on Facebook. Try this:</p> <pre><code>function pushImageToFacebook( $url_of_image , $fb_user_id , $fb_access_token ) { // Creates a new image file in the local directory and gets // ...a file handle for it. MAKE SURE that you are able to // ...write to and read from the local directory or this // ...will fail due to permissions. $fh = fopen( $filename = 'image' . microtime() , 'w' ); // Writes the image data to the local file fwrite( $fh , file_get_contents( $url_of_image ) ); // Closes the file handle fclose( $fh ); // Sets the message argument $args = array( 'message' =&gt; 'Photo Uploaded Using cURL' ); // Sets the filename argument $args[basename($filename)] = '@' . realpath($filename); // Initializes a cURL session and gets a cURL handle $ch = curl_init(); // This is your Facebook Graph API URL $url = "https://graph.facebook.com/{$fb_user_id}/photos?access_token={$fb_access_token}"; // Set all of your cURL session options 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); // Fire the cURL and grab the return data (Facebook image ID) $buffer = curl_exec($ch); // OPTIONAL : Display the Facebook image ID print_r( json_decode( $buffer , true ) ); return; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload