How do I get the title of the Facebook video using PHP.
I googled around and could not find any reference so I started trying with Facebook Graph API.
I followed using the sample given in https://developers.facebook.com/docs/graph-api/reference/video
The issue is it requires session tokens in order the get the information.
The code I used:
<?php
require_once('/vendor/facebook/php-sdk-v4/src/Facebook/FacebookRequest.php');
use Facebook\FacebookRequest;
$request = new FacebookRequest(
$session,
'GET',
'/10154392917806729'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
print_r($response);
?>
The /10154392917806729 is the video ID. It is showing "Undefined variable: session" error.
My guess is I must get the session tokens etc in order for this to work.
Is there any other simplified way? I only want to get the video title given the video url.
Is it possible?
Thanks In Advance
You have to create a facebook application at developers.facebook.com and use the client_id, secret from the same with an access token to create a new Facebook session
eg:
\FacebookSession::setDefaultApplication($client_id,$client_secret);
$session = new FacebookSession($token);
if you create a session using this code before your segment of code. It should work fine