News for Developers

Back to News

Platform Updates: Operation Developer Love

Yunnan Wu
April 22, 2011

This week, we released JS Gamebench 0.4, a more streamlined version that is easier to run. We hope you will find it helpful as you continue your development of HTML5 apps.

Using the Graph API to upload Video

As part of our efforts to transition functionality from the legacy REST API to the Graph API, we added the ability to upload videos using the Graph API. The reference documentation for the Video object lists the video formats that are supported. To publish a video, issue a POST request with the video file attachment as multipart/form-data to https://graph-video.facebook.com/me/videos. Here’s a simple PHP example:

<?php 
$app_id = "YOUR_APP_ID";
$app_secret = "YOUR_APP_SECRET"; 
$my_url = "YOUR_POST_LOGIN_URL"; 
$video_title = "YOUR_VIDEO_TITLE";
$video_desc = "YOUR_VIDEO_DESCRIPTION";

$code = $_REQUEST["code"];

if(empty($code)) {
   $dialog_url = "http://www.facebook.com/dialog/oauth?client_id=" 
     . $app_id . "&redirect_uri=" . urlencode($my_url) 
     . "&scope=publish_stream";
    echo("<script>top.location.href='" . $dialog_url . "'</script>");
}

$token_url = "https://graph.facebook.com/oauth/access_token?client_id="
    . $app_id . "&redirect_uri=" . urlencode($my_url) 
    . "&client_secret=" . $app_secret 
    . "&code=" . $code;
$access_token = file_get_contents($token_url);
 
$post_url = "https://graph-video.facebook.com/me/videos?"
    . "title=" . $video_title. "&description=" . $video_desc 
    . "&". $access_token;

echo '<form enctype="multipart/form-data" action=" '.$post_url.' "  
     method="POST">';
echo 'Please choose a file:';
echo '<input name="file" type="file">';
echo '<input type="submit" value="Upload" />';
echo '</form>';
?>

The video will be published to the uploader's own wall. Note that the URL has to be graph-video.facebook.com, not graph.facebook.com. For more information please reference the Video Graph API reference.

Photo batch uploads

Last month, we introduced batch requests to help you more efficiently request data or make changes to several objects via the Graph API. Based on developer feedback, we have continued to improve batch requests and added binary data batch uploads.

Binary data, like photos, can be specified as part of the multipart/mime portion of the batch API request. Simply add all the binary items as multipart/mime attachments to your request and have each operation reference its binary items using the "attached_files" property in the operation. The "attached_files" property can take a comma-separated list of attachment names in its value. The following example shows how to upload two photos in a single batch call:

 <?php 

 $app_id = "YOUR_APP_ID";
 $app_secret = "YOUR_APP_SECRET"; 
 $my_url = "YOUR_POST_LOGIN_URL"; 
 
 $code = $_REQUEST["code"];

if(empty($code)) {
    $dialog_url = "http://www.facebook.com/dialog/oauth?client_id=" 
        . $app_id . "&redirect_uri="  . urlencode($my_url) 
        . "&scope=publish_stream";
     echo("<script>top.location.href='" . $dialog_url . "'</script>");
 }

$token_url = "https://graph.facebook.com/oauth/access_token?client_id="
    . $app_id . "&redirect_uri=" . urlencode($my_url) 
    . "&client_secret=" . $app_secret . "&code=" . $code;

$access_token = file_get_contents($token_url);
   
$batched_request = '[{"method":"POST", "relative_url":"me/photos",' 
    . ' "body" : "message=My cat photo", "attached_files":"file1"},'
    . '{"method":"POST", "relative_url":"me/photos",' 
    . ' "body" : "message=My dog photo", "attached_files":"file2"}]';
 
$post_url = "https://graph.facebook.com/" . "?batch="
    .  urlencode($batched_request) . "&". $access_token 
    . "&method=post";
  
 echo ' <form enctype="multipart/form-data" action="'.$post_url.'" 
       method="POST">';
 echo 'Please choose 2 files:';
 echo '<input name="file1" type="file">';
 echo '<input name="file2" type="file">';
 echo '<input type="submit" value="Upload" />';
 echo '</form>';
?>

For more info, please reference the Batch API documentation.

Policy reminder: Do not create apps from fake accounts

You must not create apps with fake accounts. Facebook requires users to provide their real first and last names, and fake accounts are a violation of our Statement of Rights and Responsibilities (SRR 4.1), even when used to host or test apps. If we find that your app has fake accounts listed as an admin or developer we will disable your app. If you would like to create test users to test app functionality, you can do so here.

Fixing Bugs

Bugzilla activity for the past 7 days:

  • 179 new bugs were reported
  • 34 bugs were reproducible and accepted (after duplicates removed)
  • 6 bugs were fixed (5 previously reported bugs and 1 new bug)
  • As of today, there are 1,229 open bugs in Bugzilla (up 97 from last week)

Forum Activity

Developer Forum activity for the past 7 days:

  • 562 New Topics Created
  • 329 New Topics received a reply
  • Of those 329, 138 were replied to by a Facebook Employee
  • Of those 329, 51 were replied to by a community moderator

Please let us know if you have any questions or feedback in the comments below.


Related News

December 18 2018

December 14 2018

December 04 2018

November 28 2018