facebook php sdk登录错误:-您未连接

facebook php sdk登录错误:-您未连接,php,facebook,facebook-graph-api,facebook-php-sdk,Php,Facebook,Facebook Graph Api,Facebook Php Sdk,我正在尝试使用facbook php sdk实现一个简单的facebook登录。该代码适用于某些人,但不适用于其他人。我正在尝试获取所有权限,并在下一页以json格式显示数据 这是在用户允许所有权限并转到下一页后的输出:- 这是我正在使用的代码:- <?php require 'src/facebook.php'; set_time_limit(0); ini_set('memory_limit','2560M'); // Create our Application instance

我正在尝试使用facbook php sdk实现一个简单的facebook登录。该代码适用于某些人,但不适用于其他人。我正在尝试获取所有权限,并在下一页以json格式显示数据

这是在用户允许所有权限并转到下一页后的输出:-

这是我正在使用的代码:-

<?php
require 'src/facebook.php';
set_time_limit(0);
ini_set('memory_limit','2560M');
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
  'appId'  => 'xxxxxxxxxxxxxxxxxxxxxxxx',
  'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  'cookie' => true,
));

// Get User ID
$user = $facebook->getUser();

// We may or may not have this data based on whether the user is logged in.
//
// If we have a $user id here, it means we know the user is logged into
// Facebook, but we don't know if the access token is valid. An access
// token is invalid if the user logged out of Facebook.
$limit = 1000;
if ($user) {
  try {
    // Proceed knowing you have a logged in user who's authenticated.
    $user_profile = $facebook->api('/me');
    $statuses = $facebook->api("/me/statuses?limit=$limit");
    $albums = $facebook->api("/me/albums?limit=$limit");
    $likes = $facebook->api("/me/likes?limit=$limit");
    $activities = $facebook->api("/me/activities?limit=$limit");
    $posts = $facebook->api("/me/posts?limit=$limit");
    $events = $facebook->api("/me/events?limit=$limit");
    $notes = $facebook->api("/me/notes?limit=$limit");
    $checkins = $facebook->api("/me/checkins?limit=$limit");
    $friendlists = $facebook->api("/me/friendlists?limit=$limit");
    $friends = $facebook->api("/me/friends?limit=$limit");
    $groups = $facebook->api("/me/groups?limit=$limit");
    $interests = $facebook->api("/me/interests?limit=$limit");
    $photos = $facebook->api("/me/photos?limit=$limit");
  } catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
  }
}

// Login or logout url will be needed depending on current user state.
if ($user) {
  $logoutUrl = $facebook->getLogoutUrl();
} else {
  $loginUrl = $facebook->getLoginUrl(array(
    'scope' => 'email, user_actions.music, user_activities, user_events, user_hometown, user_location, user_questions, user_religion_politics, user_videos, publish_actions, user_actions.news, user_birthday, user_games_activity, user_interests, user_notes, user_relationship_details, user_status, user_website, user_about_me, user_actions.video, user_education_history, user_groups, user_likes, user_photos, user_relationships, user_subscriptions, user_work_history, friends_about_me, friends_actions.video, friends_education_history, friends_groups, friends_likes, friends_photos, friends_relationships, friends_subscriptions, friends_work_history, friends_actions.music, friends_activities, friends_events, friends_hometown, friends_location, friends_questions, friends_religion_politics, friends_videos, friends_actions.news, friends_birthday, friends_games_activity, friends_interests, friends_notes, friends_relationship_details, friends_status, friends_website, ads_management, export_stream, manage_notifications, photo_upload, read_friendlists, read_page_mailboxes, rsvp_event, status_update, xmpp_login, create_event, friends_online_presence, manage_pages, publish_checkins, read_insights, read_requests, share_item, user_online_presence, create_note, manage_friendlists, offline_access, publish_stream, read_mailbox, read_stream, sms, video_upload'
  ));
}

?>
<!doctype html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
  <head>
    <title>Approves it</title>
    <style>
      body {
        font-family: 'Lucida Grande', Verdana, Arial, sans-serif;
      }
      h1 a {
        text-decoration: none;
        color: #3b5998;
      }
      h1 a:hover {
        text-decoration: underline;
      }
    </style>
  </head>
  <body>
    <h1>Approves it</h1>

    <?php if ($user): ?>
      <a href="<?php echo $logoutUrl; ?>">Logout</a>
    <?php else: ?>
      <div>
        Login using OAuth 2.0 handled by the PHP SDK:
        <a href="<?php echo $loginUrl; ?>">Login with Facebook</a>
      </div>
    <?php endif ?>

    <h3>PHP Session</h3>
    <pre><?php print_r($_SESSION); ?></pre>

    <?php if ($user): ?>
      <h3>You</h3>
      <img src="https://graph.facebook.com/<?php echo $user; ?>/picture">
      <?php print_r($user); ?>
      <h3>User Profile</h3>
      <pre><?php print_r(json_encode($user_profile)); ?></pre>
      <h3>Statuses</h3>
      <?php foreach ($statuses['data'] as $status): ?>
          <pre><?php print_r(json_encode($status)); ?></pre>
      <?php endforeach; ?>
      <h3>Albums</h3>
      <pre><?php print_r(json_encode($albums)); ?></pre>
      <h3>Likes</h3>
      <pre><?php print_r(json_encode($likes)); ?></pre>
      <h3>Activities</h3>
      <pre><?php print_r(json_encode($activities)); ?></pre>
      <h3>Posts</h3>
      <?php foreach ($posts['data'] as $post): ?>
          <pre><?php print_r(json_encode($post)); ?></pre>
      <?php endforeach; ?>
      <h3>Events</h3>
      <pre><?php print_r(json_encode($events)); ?></pre>
      <h3>Notes</h3>
      <pre><?php print_r(json_encode($notes)); ?></pre>
      <h3>Checkins</h3>
      <pre><?php print_r(json_encode($checkins)); ?></pre>
      <h3>Friend Lists</h3>
      <pre><?php print_r(json_encode($friendlists)); ?></pre>
      <h3>Friends</h3>
      <pre><?php print_r(json_encode($friends)); ?></pre>
      <h3>Groups</h3>
      <pre><?php print_r(json_encode($groups)); ?></pre>
      <h3>Interests</h3>
      <pre><?php print_r(json_encode($interests)); ?></pre>
      <h3>Photos</h3>
      <?php foreach ($photos['data'] as $photo): ?>
          <pre><?php print_r(json_encode($photo)); ?></pre>
      <?php endforeach; ?>
    <?php else: ?>
      <strong><em>You are not Connected. Please login with facebook.</em></strong>
    <?php endif ?>
  </body>
</html>

批准
身体{
字体系列:“Lucida Grande”,Verdana,Arial,无衬线;
}
H1A{
文字装饰:无;
颜色:#3b5998;
}
H1A:悬停{
文字装饰:下划线;
}
批准
使用PHP SDK处理的OAuth 2.0登录:
PHP会话
你
/图片“>
用户配置文件
身份
相册
喜欢
活动
帖子
事件
笔记
签到
好友列表
朋友
组
兴趣
照片
您尚未连接。请使用facebook登录。
可通过访问以下站点复制错误:-


有人能帮我一下吗?

解决方案:在尝试了许多解决方案之后,这对我很有效

在base_facebook.php文件中,找到makeRequest()方法并检查以下行

紧跟其后,添加此行


可能对某人有帮助。我无法验证这是否是正确的解决方案,因为我不再处理该问题。
$opts = self::$CURL_OPTS;  
$opts[CURLOPT_SSL_VERIFYPEER] = false;