Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Facebook与php同步-获取Facebook数据_Facebook_Codeigniter_Facebook Graph Api - Fatal编程技术网

Facebook与php同步-获取Facebook数据

Facebook与php同步-获取Facebook数据,facebook,codeigniter,facebook-graph-api,Facebook,Codeigniter,Facebook Graph Api,我的facebook应用程序授权有问题。当我在本地web服务器上正常运行应用程序时,进程如下所示: **Get facebook user->If user is not logged on -> Redirect user on facebook login page** **Get facebook user->If user is logged on -> Redirect user to authorize my facebook application-&g

我的facebook应用程序授权有问题。当我在本地web服务器上正常运行应用程序时,进程如下所示:

**Get facebook user->If user is not logged on -> Redirect user on facebook login page**

**Get facebook user->If user is  logged on -> Redirect user to authorize my facebook application->everything goes right without problems**
当我使用iframe在facebook上托管我的应用程序时,第二个进程不起作用(用户从未获得显示授权窗口),我得到以下异常:

Error validating access token: User xxxxxxx has not authorized application xxxxxxx.
我正在使用CodeIgniter PHP框架,这是我的PHP代码:

$this->load->library('facebook');
        $user = null;
        $user_profile = null;

        $user = $this->facebook->getUser();
        if ($user) {
          try {
            // Proceed knowing you have a logged in user who's authenticated.
            $access_token = $this->facebook->getAccessToken();
            $user_profile = $this->facebook->api($user);

          } 
          catch (FacebookApiException $e) {
            show_error(print_r($e, TRUE), 500);
          }
        }
        else{
            $data = array(
            'redirect_uri' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','scope'=>'email');
            $access_token = $this->facebook->getAccessToken();
        redirect($this->facebook->getLoginUrl($data));

        }
        $data['facebook']=$user_profile;
        $this->load->view('templates/header');
        $this->load->view('pages/prijavaKlasicnoFacebook', $data);
        $this->load->view('templates/footer');
    }

由于安全原因,无法在iframe中加载OAuth对话框

您必须将其加载到最顶层的窗口实例中–因此没有服务器端重定向,而是使用
top.location.href=“…”)进行客户端“重定向”


让你的脚本在一个空文档中输出这个JS片段(包括正确的登录URL)。

你还应该在你的作用域中提供“读取流”和“发布数据”。

我不明白我需要做什么?再说一遍:不是服务器端重定向,因为这样你就呆在iframe中了–你需要“突破”它,这只能通过JS在客户端完成。因此,生成适当的JS代码,并将其交付给客户端。