• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Facebook SDK version 3.2.3 stop working

#1
I was using Facebook SDK version 3.2.3 in my Codeigniter project and was working fine some days ago. But now suddenly it stops working. I have made any change at all. The Facebook login code is given below:
Code:
/*****************************************/

public function facebook_login(){

   $output = isset($_POST['output']) && $_POST['output'] == 'json' ? "json" : "view";

   // FB OAUTH
   $this->load->library('facebook', array('appId' => 'xxxxxxxxxxxxxx', 'secret' => 'xxxxxxxxxxxxxxxxxxxxxx'));

   if (isset($_POST['access_token']) && $_POST['access_token'] != "" ){
       log_message("debug", "facebook accec token = " . $_POST['access_token']);
       $this->facebook->setAccessToken($_POST['access_token']);
   }
   // Get user's login information

   $this->user = $this->facebook->getUser();

   if ($this->user) {
       log_message("debug", "********** NODE : FB");

       $data['user_profile'] = $this->facebook->api('/me', array('fields' => 'id,name,email'));
       $data['logout_url'] = $this->facebook->getLogoutUrl(array('next' => base_url() . 'index.php/sessions/logout'));

       log_message("debug", "FACEBOOK DETAILS = " . json_encode($data));
       //log_message("debug", "FACEBOOK Login DETAILS = " . json_encode($loginUrl));
       $user_det = $this->set_social_user($data['user_profile']);


       $session_data = array(
           'user_type'  => 'social',
           'user_id'    => $user_det->id,
           'email'     => $user_det->email,
           'user_name'  => $user_det->firstname . " " . $user_det->lastname,
           'logout_url' => $data['logout_url'],
           'logged_in' => true
       );
       $_SESSION['IsAuthorized'] = 1;
       $this->session->set_userdata($session_data);

       // Get logout url of facebook

       if ($this->session->userdata('login_to_book')){
           //redirect('bookings/create_booking');
           redirect(site_url('choose_booking_address'));
       }
       else{
           if ($output == "json"){
               log_message("debug", "RETURN FB AJAX");
               return $this->output
                   ->set_content_type('application/json')
                   ->set_status_header(200)
                   ->set_output(json_encode(array(
                           'success' => true,
                           'message' => 'Success!',
                           'username'=> $this->session->userdata('user_name')
                   )));
           }
           else{
               $this->display_home($data);
               return;
           }
       }
   }
   else {

       $fb_data = array(
       'scope' => 'email',
       'redirect_url'  => site_url('facebook_login'));

       $data['fb_login_url'] = $this->facebook->getLoginUrl($fb_data);
       //$this->load->view('login', $data);
       log_message("debug", "FB LOGIN URL = " . $data['fb_login_url']);
       redirect($data['fb_login_url'], 'refresh');
   }
}

anyone can help me ?
Reply

#2
(08-26-2017, 06:20 AM)[email protected] Wrote: I was using Facebook SDK version 3.2.3 in my Codeigniter project and was working fine some days ago. But now suddenly it stops working. I have made any change at all. The Facebook login code is given below:
Code:
/*****************************************/

public function facebook_login(){

   $output = isset($_POST['output']) && $_POST['output'] == 'json' ? "json" : "view";

   // FB OAUTH
   $this->load->library('facebook', array('appId' => 'xxxxxxxxxxxxxx', 'secret' => 'xxxxxxxxxxxxxxxxxxxxxx'));

   if (isset($_POST['access_token']) && $_POST['access_token'] != "" ){
       log_message("debug", "facebook accec token = " . $_POST['access_token']);
       $this->facebook->setAccessToken($_POST['access_token']);
   }
   // Get user's login information

   $this->user = $this->facebook->getUser();

   if ($this->user) {
       log_message("debug", "********** NODE : FB");

       $data['user_profile'] = $this->facebook->api('/me', array('fields' => 'id,name,email'));
       $data['logout_url'] = $this->facebook->getLogoutUrl(array('next' => base_url() . 'index.php/sessions/logout'));

       log_message("debug", "FACEBOOK DETAILS = " . json_encode($data));
       //log_message("debug", "FACEBOOK Login DETAILS = " . json_encode($loginUrl));
       $user_det = $this->set_social_user($data['user_profile']);


       $session_data = array(
           'user_type'  => 'social',
           'user_id'    => $user_det->id,
           'email'     => $user_det->email,
           'user_name'  => $user_det->firstname . " " . $user_det->lastname,
           'logout_url' => $data['logout_url'],
           'logged_in' => true
       );
       $_SESSION['IsAuthorized'] = 1;
       $this->session->set_userdata($session_data);

       // Get logout url of facebook

       if ($this->session->userdata('login_to_book')){
           //redirect('bookings/create_booking');
           redirect(site_url('choose_booking_address'));
       }
       else{
           if ($output == "json"){
               log_message("debug", "RETURN FB AJAX");
               return $this->output
                   ->set_content_type('application/json')
                   ->set_status_header(200)
                   ->set_output(json_encode(array(
                           'success' => true,
                           'message' => 'Success!',
                           'username'=> $this->session->userdata('user_name')
                   )));
           }
           else{
               $this->display_home($data);
               return;
           }
       }
   }
   else {

       $fb_data = array(
       'scope' => 'email',
       'redirect_url'  => site_url('facebook_login'));

       $data['fb_login_url'] = $this->facebook->getLoginUrl($fb_data);
       //$this->load->view('login', $data);
       log_message("debug", "FB LOGIN URL = " . $data['fb_login_url']);
       redirect($data['fb_login_url'], 'refresh');
   }
}

anyone can help me ?

The current sdk version is 5.6.

https://github.com/facebook/php-graph-sdk
Reply

#3
I have checked the code which I added above briefly. Here I noticed that $this->facebook->getUser() function always returns zero.I am sure that the app id and secret key which I have given are correct. Any idea?
Reply

#4
At last found the solution from this stack overflow question and its second answer solved my issue.
https://stackoverflow.com/questions/2136...eturning-0
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.