dourong9253 2016-03-14 09:15
浏览 45

获取Facebook视频的标题

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

  • 写回答

1条回答 默认 最新

  • douxiluan6555 2016-03-14 09:29
    关注

    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

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题