Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To upload images to a facebook page of which you're an admin you need to do the following:</p> <p>1.) Create a facebook application (the usual way), make sure you specify the Canvas URL</p> <p>2.) Navigate to the url below logged in as the admin of the page, and give the permissions (user_photos,manage_pages,offline_access,publish_stream)</p> <pre><code>https://www.facebook.com/dialog/oauth? client_id=&lt;application_id&gt; &amp;redirect_uri=&lt;canvas_url&gt; &amp;response_type=token &amp;scope=user_photos,manage_pages,offline_access,publish_stream </code></pre> <p>3.) When you give the application the required permissions you'll be redirected to canvas_url#access_token=*access_token*, for example </p> <pre><code>http://example.com/#access_token=awe12 </code></pre> <p>4.) Then navigate to </p> <pre><code>https://graph.facebook.com/me/accounts?access_token=&lt;access_token&gt; </code></pre> <p>(use the access token from #3). This will list the pages you administer; write down the access_token for the page(s) to which you want to upload the image</p> <p>I'm not 100% sure but I believe that using graph api you can upload images only to albums created via graph api; i.e. you need to first create an album via graph api. Here's sample code using curl:</p> <pre><code>$uri = sprintf( 'https://graph.facebook.com/%1$s/albums?access_token=%2$s', $page_id, $access_token ); $post_fields = array( 'name' =&gt; trim( $album_name ) ); $curl = curl_init( $uri ); curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt( $curl, CURLOPT_POST, TRUE ); curl_setopt( $curl, CURLOPT_POSTFIELDS, $post_fields ); $raw_data = curl_exec( $curl ); curl_close( $curl ); $data = json_decode( $raw_data, $assoc = TRUE ); </code></pre> <p>The <code>$data</code> above will contain the album id, which you'll need to upload a photo:</p> <pre><code>// prepare the curl post fields $batch = sprintf( '[{"method":"POST", "relative_url":"%1$s/photos", "attached_files":"file1"}]', $album_id ); $post_fields = array( 'batch' =&gt; $batch, 'access_token' =&gt; $access_token, 'file1' =&gt; '@' . $image_abs_path ); $uri = 'https://graph.facebook.com'; $curl = curl_init( $uri ); curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt( $curl, CURLOPT_POST, TRUE ); curl_setopt( $curl, CURLOPT_POSTFIELDS, $post_fields ); $raw_data = curl_exec( $curl ); curl_close( $curl ); $data = json_decode( $raw_data, $assoc = TRUE ); </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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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