0

Facebook redirect back with a token but user is still null or 0

        $settings = $this->social_model->get_facebook_settings();

        // Create our Application instance (replace this with your appId and secret).
        $facebook = new Facebook(array(
          'appId'  => $settings[0]['value'],
          'secret' => $settings[1]['value'],
        ));
        // GET CURRENT USER
        $user = $facebook->getUser();

        if ($user) {
          try {
            // Proceed knowing you have a logged in user who's authenticated.
            $user_profile = $facebook->api('/me');
          } catch (FacebookApiException $e) {
            error_log($e);
            $user = null;
          }
        }

        // CHECKS IF NOT LOGIN
        if($user == 0){
            $params = array(
              'scope' => 'publish_stream,publish_actions,manage_pages,status_update,offline_access',
              'redirect_uri' => site_url('admin/social/add_facebook')
            );
            $loginUrl = $facebook->getLoginUrl($params);
            echo "<script> window.location = '$loginUrl';</script>";
        }else{

            $user_accounts  = $facebook->api('/me/accounts');
            foreach ($user_accounts['data'] as $key => $value) {
                    $this->social_model->insert_facebook_page($value['name'],$value['access_token'],$value['id']);
            }
        }
4

1 回答 1

0

我能够修复它。我编辑了类文件并将 $_REQUEST 替换为 $_GET。添加了 CURLOPT_SSL_VERIFYPEER => false,

于 2013-09-22T01:20:35.810 回答