为什么 Facebook PHP SDK getUser 总是返回 0?打开购物车

Why is Facebook PHP SDK getUser always returning 0? Opencart

我在 OpenCart2.1.x.

中访问 $this->fbconnect->getUser(); 时得到 0 结果

下面是我正在使用的代码:

register.tpl 中的 URL 没问题,我被重定向到 FB 登录页面进行身份验证。但是在返回我的网站时登录后,我得到 0getUser() 功能。

完整代码可以在这里找到:: Click Here

我的应用设置是:

此处:: abc.com 表示我的实际网站 URL 将被替换为此处。

Please do not mark this question as DUPLICATE because i have already searched on SO and everywhere and nothing is working here for me. So, please try to give the solution and that is i am posting question after searching for more than 1 day.

试试这个 ;)

替换

echo $fbuser = $this->fbconnect->getUser();

try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $this->fbconnect->get('/me?fields=id,name', '{access-token}');
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}

$user = $response->getGraphUser();

echo 'Id: ' . $user['id'];
echo 'Name: ' . $user['name'];