dongse7261 2017-03-01 13:55
浏览 43

Facebook响应API无法在CodeIgniter中运行?

I am creating a web app in codeigniter with facebook login, and while sending I have created a API Key and also a response redirect_uri.

The problem here is while executing the project in the separate file, it's working fine, but when I was trying to integrate to my project. Facebook is asking for permission to enter to the app that's working fine. But the problem is I'm not getting any response from Facebook to display values and store it in the database.

The code which I was sing in my project is shown below. Codeigniter coding format

application
   /----config
        /----facebook.php // "contains the appId & secret Key"
   /----controller
        /----book_your_service.php //"contains the facebook_request & facebook_response"
   /----libraries
        /----Fbconnect.php //contains the URL send and Response
        /----facebook  "Library file downloaded from github"
             /----facebook.php
             /----base-facebook.php

Following code is for libraries --> Fbconnect.php

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

include (APPPATH.'libraries/facebook/facebook.php');

class Fbconnect extends Facebook
{
  public $user = NULL;
  public $user_id = NULL;
  public $fb = false;
  public $fbSession = false;
  public $appkey = 0;

  public function Fbconnect(){

    $ci =& get_instance();
    $ci->config->load('facebook', TRUE);
    $config = $ci->config->item('facebook');
    parent::__construct($config);

    $this->user_id = $this->getUser();

    //print_r($this->user_id);
    $me = null;
    if($this->user_id){
      try{
        $me = $this->api('/me');
        //echo $me;
        $this->user = $me;
      }catch(FacebookApiException $e){
        error_log($e);
      }

    }
  }
} 

the following code used in book_your.php for sending and receiving the response from facebook.

// Facebook Login API Code
  public function facebook_request()
  {
    $this->load->library('fbconnect');
    $data = array(
      'redirect_uri' => site_url('book_your_service/facebook_response'),
      'scope' => 'email'
    );
    redirect($this->fbconnect->getLoginUrl($data));
  }
  public function facebook_login()
  {
    //session_start();
    $this->load->library('fbconnect');
    if($this->fbconnect->user){
    echo"<pre>";
    print_r($this->fbconnect->user);
    echo"</pre>";
    }else{
    echo "Could not connect this time";
    }
  }

The facebook Bundle which I was using in this project is shown below https://github.com/puneetkay/Facebook-PHP-CodeIgniter.git

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?
    • ¥15 matlab(相关搜索:紧聚焦)
    • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
    • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
    • ¥50 需求一个up主付费课程