Back to News for Developers

Platform Updates: Operation Developer Love

July 22, 2011ByPaul Carduner

This week, we updated the JavaScript SDK to support OAuth 2.0 and extended the timeline for apps to migrate to OAuth 2.0 by October 1st.

Dark background for the Facepile plugin

Similiar to other social plugins, the Facepile plugin is now also available in the dark color scheme.

You can preview Facepile in the dark background by toggling the 'color scheme' field to 'dark' in the Facepile configurator.

<br/> <br/>

Uploading Photos to the Graph API via a URL

Earlier this year, we released support for uploading photos directly via the Graph API. This requires sending the photo as a MIME-encoded form field. We are now enhancing our photo upload capability by introducing the ability to upload photos simply by providing a URL to the image. This simplifies photo management for a number of use cases:

  • App developers who host their images on Amazon S3 or a similar service can pass the S3 URL directly to Facebook without having to download the file to their application servers only to upload it again to Facebook. This improves performance and reduces costs for developers.
  • Apps written on platforms that don't have good support for multipart file uploads can create new photos more easily.

To upload a photo via a URL, simply issue an HTTP POST to ALBUM_ID/photos with the url field set to the URL of the photo you wish to upload. You need the publish_streampermission to perform this operation. You can also include an optional message parameter to set a caption for the photo. For example:

&lt;?php
  $app_id = &quot;APP_ID&quot;;
  $app_secret = &quot;APP_SECRET&quot;;
  $post_login_url = &quot;POST_AUTH_REDIRECT_URL&quot;;
  $album_id = &quot;ALBUM_ID&quot;;
  $photo_url = &quot;PHOTO_URL&quot;;
  $photo_caption = &quot;PHOTO_CAPTION&quot;;

  $code = $_REQUEST[&quot;code&quot;];

  //Obtain the access_token with publish_stream permission 
  if (!$code){ 
    $dialog_url= &quot;http://www.facebook.com/dialog/oauth?&quot;
      . &quot;client_id=&quot; .  $app_id
      . &quot;&amp;redirect_uri=&quot; . urlencode( $post_login_url)
      .  &quot;&amp;scope=publish_stream&quot;;
    echo(&quot;&lt;script&gt;top.location.href='&quot; . $dialog_url
      . &quot;'&lt;/script&gt;&quot;);
  } else {
    $token_url=&quot;https://graph.facebook.com/oauth/access_token?&quot;
      . &quot;client_id=&quot; . $app_id
      . &quot;&amp;client_secret=&quot; . $app_secret
      . &quot;&amp;redirect_uri=&quot; . urlencode( $post_login_url)
      . &quot;&amp;code=&quot; . $code;
    $response = file_get_contents($token_url);
    $params = null;
    parse_str($response, $params);
    $access_token = $params['access_token'];

    // POST to Graph API endpoint to upload photos
    $graph_url= &quot;https://graph.facebook.com/&quot; 
      . $album_id . &quot;/photos?&quot;
      . &quot;url=&quot; . urlencode($photo_url)
      . &quot;&amp;message=&quot; . urlencode($photo_caption)
      . &quot;&amp;method=POST&quot;
      . &quot;&amp;access_token=&quot; .$access_token;

    echo '&lt;html&gt;&lt;body&gt;';
    echo file_get_contents($graph_url);
    echo '&lt;/body&gt;&lt;/html&gt;';
  }
?&gt;

The HTTP POST may take some time to complete, depending on picture size, network availability, etc.

Attaching Existing Facebook Photos to Wall Posts

This week we released the ability to attach existing Facebook photos from a user’s album to new posts on their Wall. To do this, issue an HTTP POST to USER_ID/feed with the Post object parameters. Include an object_attachment parameter which specifies the photo ID of the photo you wish to attach to the post. The User must be the owner of the photo, and the photo cannot be part of a message attachment.

For example:

&lt;?php
  $app_id = &quot;APP_ID&quot;;
  $app_secret = &quot;APP_SECRET&quot;;
  $post_login_url = &quot;POST_AUTH_REDIRECT_URL&quot;;
  $photo_id = &quot;PHOTO_ID&quot;;
  $wall_message = &quot;MESSAGE_FOR_POST&quot;;
  $wall_link = &quot;LINK_TO_POST&quot;;
  $user_id = &quot;USER_ID&quot;;

  $code = $_REQUEST[&quot;code&quot;];

  // Obtain the access_token with publish_stream permission 
  if (!$code) {
    $dialog_url= &quot;http://www.facebook.com/dialog/oauth?&quot;
      . &quot;client_id=&quot; .  $app_id
      . &quot;&amp;redirect_uri=&quot; . urlencode( $post_login_url)
      .  &quot;&amp;scope=publish_stream&quot;;
    echo(&quot;&lt;script&gt;top.location.href='&quot; . $dialog_url
      . &quot;'&lt;/script&gt;&quot;);
  } else {
    $token_url=&quot;https://graph.facebook.com/oauth/access_token?&quot;
      . &quot;client_id=&quot; . $app_id
      . &quot;&amp;redirect_uri=&quot; . urlencode( $post_login_url)
      . &quot;&amp;client_secret=&quot; . $app_secret
      . &quot;&amp;code=&quot; . $code;
    $response = file_get_contents($token_url);
    $params = null;
    parse_str($response, $params);
    $access_token = $params['access_token'];

    // POST to Graph API feed endpoint, which is the user's Wall
    $graph_url= &quot;https://graph.facebook.com/&quot; . $user_id . &quot;/feed?&quot;
      . &quot;message=&quot; . urlencode($wall_message)
      . &quot;&amp;link=&quot; . urlencode($wall_link)
      . &quot;&amp;object_attachment=&quot; . $photo_id
      . &quot;&amp;method=POST&quot;
      . &quot;&amp;access_token=&quot; .$access_token;

    echo '&lt;html&gt;&lt;body&gt;';
    echo file_get_contents($graph_url);
    echo '&lt;/body&gt;&lt;/html&gt;';
  }
?&gt;

See the /posts connection on the Graph API User object for further details.

Documentation Activity for the Last Seven Days

We have updated the FQL documentation for the following tables:

103 docs are under review

Fixing Bugs

Bugzilla activity for the past 7 days:

  • 201 new bugs were reported
  • 71 bugs were reproducible and accepted (after duplicates removed)
  • 20 bugs were fixed (16 previously reported bugs and 4 new bugs)
  • As of today, there are 1,288 open bugs in Bugzilla (down 82 from last week)

Forum Activity

Developer Forum activity for the past 7 days:

  • 442 New Topics Created
  • 176 New Topics received a reply
  • 13% received a reply from a community moderator or a Facebook employee

Tags: