繁体   English   中英

Facebook api 5V收到电子邮件

[英]Facebook api 5V get email

我在使用php从Facebook sdk获取电子邮件地址时遇到了麻烦。

错误信息:

注意:未定义的变量:第94行的/storage/h5/727/1013727/public_html/index.php中的请求

致命错误:未捕获错误:在/storage/h5/727/1013727/public_html/index.php:94中调用null上的成员函数execute()堆栈跟踪:

{94}在第94行的/storage/h5/727/1013727/public_html/index.php中抛出

我的代码是:

    <?php
  /* PHP SDK v5.0.0 */
/* make the API call */
$request = new FacebookRequest(
  $session,
  'GET',
  '/{email}'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */
    ?>

我唯一需要的是:

require_once __DIR__ . '/facebook-sdk-v5/autoload.php';

我应该制作一个加载一切的config.php吗? 如果有的话,你知道因为我找不到一个(V5)

从官方的Facebook PHP SDK文档中 ,您应该这样做:

$fb = new \Facebook\Facebook([
  'app_id' => '{app-id}',
  'app_secret' => '{app-secret}',
  'default_graph_version' => 'v2.8',
  //'default_access_token' => '{access-token}', // optional
]);

$response = $fb->get('/{user-id}?fields=email', '{access-token}');

$user = $response->getGraphUser();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM