Back to News for Developers

Platform Updates: Operation Developer Love

June 17, 2011ByFran Larkin

Reminder: Required Migration to Facebook Credits by July 1st

Effective July 1, we will require social game developers on Facebook Platform to process all payments through Facebook Credits, as we announced in January. Any games that are not using Facebook Credits exclusively on July 1st will be subject to enforcement action. For information on implementation options and best practices, please see our Credits Migration page. To learn more or follow the latest news on Facebook Credits, visit the Credits page on the Developer Site.

New Payment Methods and Workflows for Facebook Credits

This week, we announced alternative payment methods for Facebook Credits, in 13 countries in Asia and Latin America. In addition, we’ve developed a new payout process that allows us to support payouts to developers in nearly all countries globally. See the announcement for more details.

The New Send Dialog

This week, we also released a companion to the Send button, the Send Dialog. Like the Send button, the Send Dialog allows users to send content to specific people and groups, and is useful for doing deep integration with Facebook Messages. The Send Dialog resembles the Feed Dialog in implementation. Check out the details in our blog post and in the reference documentation.

Uploading Videos to an Application, Group, or Page via the Graph API

We continue to transition from the REST API to the Graph API. In addition to a user’s wall, you can now upload videos directly to a Application, Group, or Page’s wall. The reference documentation for the Video object lists the video formats that are supported.

<br/><br/>

Uploading a Video to a Group

Posting a video to a Group requires the publish_stream permission and is accomplished exactly the same way as uploading a video to a user’s wall, with the single exception that you must replace the user (‘me’, the user’s login name, or the USER_ID) in the Graph API URL with the appropriate GROUP_ID:

&lt;?php
$app_id = &quot;YOUR_APP_ID&quot;;
$app_secret = &quot;YOUR_APP_SECRET&quot;;
$my_url = &quot;YOUR_POST_LOGIN_URL&quot;;
$video_title = &quot;TITLE FOR THE VIDEO&quot;;
$video_desc = &quot;DESCRIPTION FOR THE VIDEO&quot;;
$group_id = &quot;YOUR_GROUP_ID&quot;;

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

echo '&lt;html&gt;&lt;body&gt;';

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

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

$post_url = &quot;https://graph-video.facebook.com/&quot; . $group_id . &quot;/videos?&quot;
    . &quot;title=&quot; . $video_title. &quot;&amp;description=&quot; . $video_desc
    . &quot;&amp;&quot;. $access_token;

echo '&lt;form enctype=&quot;multipart/form-data&quot; action=&quot; '.$post_url.' &quot;  
     method=&quot;POST&quot;&gt;';
echo 'Please choose a file:';
echo '&lt;input name=&quot;file&quot; type=&quot;file&quot;&gt;';
echo '&lt;input type=&quot;submit&quot; value=&quot;Upload&quot; /&gt;';
echo '&lt;/form&gt;';

echo '&lt;/body&gt;&lt;/html&gt;';
?&gt;

<br/> When the upload completes, the VIDEO_ID of the new Video object will be returned. <br/>

<br/>

Uploading a Video to an Application or Page

Uploading a video to an Application or Page is similar to uploading to a User or Group’s wall, but you must use an access token specifically for the Application or Page to which you want to upload the video. To get this access token, you request the manage_pages permission (in addition to publish_stream) and then get the access token for the account (Application or Page). To do this, issue an HTTP GET to /USER_ID/accounts. This will return an array of objects containing id, name, category, and access_token fields for each Application or Page the user has access to. You can then use the appropriate access token from this list to perform the upload using the same method as above:

&lt;?php
$app_id = &quot;YOUR_APP_ID&quot;;
$app_secret = &quot;YOUR_APP_SECRET&quot;;
$my_url = &quot;YOUR_POST_LOGIN_URL&quot;;
$video_title = &quot;TITLE FOR THE VIDEO&quot;;
$video_desc = &quot;DESCRIPTION FOR THE VIDEO&quot;;
$page_id = &quot;YOUR_PAGE_ID&quot;; // Set this to your APP_ID for Applications

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

echo '&lt;html&gt;&lt;body&gt;';

if(empty($code)) {
  // Get permission from the user to publish to their page. 
  $dialog_url = &quot;http://www.facebook.com/dialog/oauth?client_id=&quot;
    . $app_id . &quot;&amp;redirect_uri=&quot; . urlencode($my_url)
    . &quot;&amp;scope=publish_stream,manage_pages&quot;;
  echo('&lt;script&gt;top.location.href=&quot;' . $dialog_url . '&quot;;&lt;/script&gt;');
} else {

  // Get access token for the user, so we can GET /me/accounts
  $token_url = &quot;https://graph.facebook.com/oauth/access_token?client_id=&quot;
      . $app_id . &quot;&amp;redirect_uri=&quot; . urlencode($my_url)
      . &quot;&amp;client_secret=&quot; . $app_secret
      . &quot;&amp;code=&quot; . $code;
  $access_token = file_get_contents($token_url);

  $accounts_url = &quot;https://graph.facebook.com/me/accounts?&quot; . $access_token;
  $response = file_get_contents($accounts_url);

  // Parse the return value and get the array of accounts we have
  // access to. This is returned in the data[] array. 
  $resp_obj = json_decode($response,true);
  $accounts = $resp_obj['data'];

  // Find the access token for the page to which we want to post the video.
  foreach($accounts as $account) {
       if($account['id'] == $page_id) {
         $access_token = $account['access_token'];
         break;
       }
  }

  // Using the page access token from above, create the POST action
  // that our form will use to upload the video.
  $post_url = &quot;https://graph-video.facebook.com/&quot; . $page_id . &quot;/videos?&quot;
      . &quot;title=&quot; . $video_title. &quot;&amp;description=&quot; . $video_desc
      . &quot;&amp;access_token=&quot;. $access_token;

  // Create a simple form 
  echo '&lt;form enctype=&quot;multipart/form-data&quot; action=&quot; '.$post_url.' &quot;  
       method=&quot;POST&quot;&gt;';
  echo 'Please choose a file:';
  echo '&lt;input name=&quot;file&quot; type=&quot;file&quot;&gt;';
  echo '&lt;input type=&quot;submit&quot; value=&quot;Upload&quot; /&gt;';
  echo '&lt;/form&gt;';
}

echo '&lt;/body&gt;&lt;/html&gt;';
?&gt;

<br/> As above, when the upload completes, the VIDEO_ID of the new Video object will be returned. <br/> <br/> NOTE: It may take several minutes for uploaded videos to be visible on the Application, Page or Group’s wall.

<br/><br/>

Documentation activity for the past 7 days

We updated the Graph API docs for the <br/><br/>

Fixing Bugs

Bugzilla activity for the past 7 days:

  • 135 new bugs were reported
  • 26 bugs were reproducible and accepted (after duplicates removed)
  • 11 bugs were fixed (10 previously reported bugs and 1 new bug)
  • As of today, there are 1,289 open bugs in Bugzilla (up 27 from last week)

Forum Activity

Developer Forum activity for the past 7 days:

  • 502 New Topics Created
  • 213 New Topics received a reply
  • 21.60% received a reply from a community moderator or a Facebook employee

Fran Larkin, who works in product marketing, just uploaded a video using the Graph API


Tags: