Since it was not so easy for me to get things up and running, I wanted to share it for other developers. This code gets all videos that are uploaded to a page. First you should download the php sdk from github.
<?php
require_once 'facebook.php';
$app_id = "226102437478452"; //Your application ID
$canvas_page = "http://apps.facebook.com/your_canvas_page/"; //Your canvas page
$secret = '1b919de960ba93165650c2385a5b1c7e'; //Your application secret
$auth_url = "http://www.facebook.com/dialog/oauth?client_id="
. $app_id . "&redirect_uri=" . urlencode($canvas_page);
$signed_request = $_REQUEST["signed_request"];
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
$data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);
if (empty($data["user_id"])) {
echo("<script> top.location.href='" . $auth_url . "'</script>");
} else {
//this uses the facebook object from facebook.php
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $secret,
));
$user_id = $facebook->getUser();
//page id
$page_id = '134501956646782';
$page_data = $facebook->api('/'.$page_id.'/videos/uploaded');
print_r($page_data);
}
?>
One Comment
This is a good basic example. It’s helpful to see a couple pieces of code from Facebook’s docs combined in one example.