[英]Facebook-PHP-SDK: api('/me') not working, very strange
這是我的代碼:
$session = $facebook->getSession();
var_dump($session);/*it says session is perfectly established*/
try {
$uid = $facebook->getUser();
echo '<br>';
var_dump($uid);/*User id is found*/
$fb_user = $me = $facebook->api('/me');/*PHP execution doesn't go forward, here it breaks*/
echo '<br>';
var_dump($fb_user);/*PHP execution doesn't come up to here*/
編輯:我在catch部分有print_r $ exception並得到以下長消息:
FacebookApiException Object
(
[result:protected] => Array
(
[error_code] => 6
[error] => Array
(
[message] => name lookup timed out
[type] => CurlException
)
)
[message:protected] => name lookup timed out
[string:private] =>
[code:protected] => 6
[file:protected] => /home/abusadat/public_html/.../facebook.php
[line:protected] => 614
[trace:private] => Array
(
[0] => Array
(
[file] => /home/abusadat/public_html/.../facebook.php
[line] => 575
[function] => makeRequest
[class] => Facebook
[type] => ->
[args] => Array
(
[0] => https://graph.facebook.com/me
[1] => Array
(
[method] => GET
[access_token] => ******...******
)
)
)
[1] => Array
(
[file] => /home/abusadat/public_html/.../facebook.php
[line] => 539
[function] => _oauthRequest
[class] => Facebook
[type] => ->
[args] => Array
(
[0] => https://graph.facebook.com/me
[1] => Array
(
[method] => GET
)
)
)
[2] => Array
(
[file] => /home/abusadat/public_html/.../facebook.php
[line] => 492
[function] => _graph
[class] => Facebook
[type] => ->
[args] => Array
(
[0] => /me
)
)
[3] => Array
(
[file] => /home/abusadat/public_html/.../fb-connect.php
[line] => 31
[function] => api
[class] => Facebook
[type] => ->
[args] => Array
(
[0] => Array
(
[0] => Facebook Object
(
[appId:protected] => ******...******
[session:protected] => Array
(
[access_token] => ******...******
[base_domain] => abusadat.com
[expires] => 1312567200
[secret] => ******...******
[session_key] => ******...******
[sig] => ******...******
[uid] => ******...******
)
[signedRequest:protected] =>
[sessionLoaded:protected] => 1
[cookieSupport:protected] => 1
[baseDomain:protected] =>
[fileUploadSupport:protected] =>
)
[1] => _graph
)
[1] => Array
(
[0] => /me
)
)
)
[4] => Array
(
[file] => /home/abusadat/public_html/.../index.php
[line] => 29
[args] => Array
(
[0] => /home/abusadat/public_html/.../fb-connect.php
)
[function] => include_once
)
)
)
我正在使用SDK版本2.1.2。 我對使用SDK 3或更高版本有一些限制。
我的猜測是,正在引發異常,並且您沒有看到此異常,因為您的PHP錯誤報告設置未正確調整。
將此添加到您的PHP文件的頂部:
ini_set('display_errors', 1);
error_reporting(E_ALL);
然后,您應該在訪問頁面時看到PHP錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.