我使用下面的代码在facebook应用程序中使用评论社交插件
<div class="fb-comments" data-href="<?php echo $fbconfig['appBaseUrl']; ?>" data-num-posts="20" data-width="480"></div>
$ fbconfig [&#39; appBaseUrl&#39;]是我的facebook app url(http://apps.facebook.com/ [appname])
当用户发表评论时,评论会在时间线上显示评论,但也会显示以下异常:
"Uncaught Exception: 100: null does not resolve to a valid user ID"
我尝试过使用开放图调试器但没有提供更多信息,除了206响应代码
http://developers.facebook.com/tools/debug/og/object?q=apps.facebook.com%2Fmesresolutions
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<br><b>Fatal error</b>
</head>
<body><p>: Uncaught Exception: 100: null does not resolve to a valid user ID
thrown in <b>/home/kastelni/www/facebook/mesresolutions/fb/base_facebook.php</b> on line <b>708</b><br></p></body>
</html>
你知道我的应用程序或插件有什么问题吗? 需要一些帮助;)
感谢您的帮助! 晏
答案 0 :(得分:1)
找到了解决方案。
我正在测试当前用户是否是我的应用程序的粉丝。 但如果这是用户的第一次连接,则无法这样做。
对于那些对一段代码感兴趣的人:
$user = $facebook->getUser();
$loginUrl = $facebook->getLoginUrl(
array(
//'scope' => 'email,publish_stream,user_birthday,user_location,user_work_history,user_about_me,user_hometown'
'scope' => 'user_about_me'
)
);
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
$user_perm = $facebook->api('/me/permissions');
} catch (FacebookApiException $e) {
//you should use error_log($e); instead of printing the info on browser
//d($e); // d is a debug function defined at the end of this file
$user = null;
}
}
try
{
if(isset($user_profile['id']))
{
//Est-ce que l'utilisateur est FAN
$isFan = $facebook->api(array(
"method" => "pages.isFan",
"page_id" => $fbconfig['pageId'],
"uid" => $user_profile['id']
));
}
else
$isFan = 0;
}
catch(Exception $o){
$isFan = 0;
}