FbDevWiki is for sale on Flippa. Please take a look at the page if you're interested. There's only a few days left to the auction!

Graph:Video

From Facebook Developer Wiki (FbDevWiki.com)
Jump to: navigation, search

An individual video

Contents

Example

https://graph.facebook.com/614004947048 (A tech talk on Tornado)

Properties

Name Description Permissions Returns Condition
id The video ID Available to everyone on Facebook by default JSON string
from The profile (user or page) that created the video Available to everyone on Facebook by default JSON object containing id and name fields
tags The users who are tagged in this video Available to everyone on Facebook by default An array of JSON objects containing id and name fields
name The video title or caption Available to everyone on Facebook by default JSON string
embed_html The html element that may be embedded in an Web page to play the video Available to everyone on Facebook by default JSON string containing a valid URL
icon The icon that Facebook displays when video are published to the Feed Available to everyone on Facebook by default JSON string containing a valid URL
source URL to the raw, playable video file Available to everyone on Facebook by default JSON string containing a valid URL
created_time The time the video was initially published Available to everyone on Facebook by default JSON string containing a IETF RFC 3339 datetime
updated_time The last time the video or its caption were updated Available to everyone on Facebook by default JSON string containing a IETF RFC 3339 datetime


Connections

Name Description Permissions Returns
likes All of the likes on this video Available to everyone on Facebook by default An array of JSON objects containing id and name fields
comments All of the comments on this video Available to everyone on Facebook by default An array of JSON objects containing id, from, message and created_time fields
picture The image which represents the content of the video Available to everyone on Facebook by default HTTP 302 with the URL of the album's cover

Publishing

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.

Personal tools
Namespaces
Variants
Actions
Navigation
Graph API
FQL
Toolbox