Welcome Guest, Not a member yet? Register   Sign In
Facebook Integration Problem
#1

[eluser]jdav3579[/eluser]
Hi,
After scouring numerous posts on this subject, I cant seem to get my Facebook application to connect.
In my htaccess:
Code:
#Force PHP5
#remove comments below for live site
#also in config change this $config['index_page'] = "index.php?"; to this $config['index_page'] = "";
AddType x-mapp-php5 .php

RewriteEngine on
RewriteCond $1 !^(index\.php|images|styles|scripts|favicon\.ico|favicon\.png|robots\.txt|sitemap\.xml)
RewriteRule ^(.*)$ index.php?/$1 [L]
My config:
Code:
$config['uri_protocol']    = "AUTO";
$config['enable_query_strings'] = TRUE;

In my application:
Code:
class fb extends MY_Controller {

    private $facebook;

    function fb(){
        parent::MY_controller();
        $this->load->helper('facebook/facebook');
        $this->facebook = new Facebook(array(
                  'appId' => 'xxxxx',
                  'secret' => 'xxxxx'
                ));
    }

    function index(){
        $session = $this->facebook->getSession();
      
    }

}

It would appear that no session is being set. Can anyone possibly point me in the right direction at all please?
#2

[eluser]bretticus[/eluser]
How are you referring to your class since you have enabled querystrings? The manual gives the following example with querystrings enabled (with your controller and method substitutedSmile

Quote:index.php?c=fb&m=index&id=345

How do you know your session is not being set? What kind of feedback/error are you getting?
#3

[eluser]jdav3579[/eluser]
Hi, Thanks for the reply. I was trying various configuration options, with and without query strings enabled.I will try it without query strings enabled - but I think facebook was adding data onto the end of the query string which was confusing CI.

I tested to see if the session was being set by var_dumping 'session' after this line:
Code:
$session = $this->facebook->getSession();
#4

[eluser]bretticus[/eluser]
[quote author="jdav3579" date="1288097656"]I tested to see if the session was being set by var_dumping 'session' after this line:
Code:
$session = $this->facebook->getSession();
[/quote]

So what was it returning?
#5

[eluser]jdav3579[/eluser]
Hi,
It was just returning (NULL).
Cheers
#6

[eluser]bretticus[/eluser]
Here's some code from a facebook app I've been playing with using CodeIgniter. It hides index.php but I'm using a hack to get GET data also. enable querystrings is OFF.

Code:
class Myapp extends Controller {

    function __construct() {
        parent::Controller();
        //get GET vars
        parse_str(substr(strrchr($_SERVER['REQUEST_URI'], "?"), 1), $_GET);
    }

    function index() {

        $data = array();

        $this->load->config('myapp');
        $this->load->library('facebook', $this->config->item('fb_settings'));

        $data['session'] = $this->facebook->getSession();

        $data['me'] = null;
        if ($data['session']) {
            try {
                $data['uid'] = $this->facebook->getUser();
                $data['me'] = $this->facebook->api('/me');
            } catch (FacebookApiException $e) {
                error_log($e);
            }
        }

        // login or logout url will be needed depending on current user state.
        if ($data['me']) {
            $data['logout_url'] = $this->facebook->getLogoutUrl();
        } else {
            $data['login_url'] = $this->facebook->getLoginUrl();
        }

        // This call will always work since we are fetching public data.
        $data['bretticus'] = $this->facebook->api('/bretticus');

        $data['app_id'] = $this->facebook->getAppId();
        
        $this->load->view('myapp/canvas', $data);
    }
}
#7

[eluser]jdav3579[/eluser]
Hi Bretticus,
Thanks for your help! much appreciated. I have been kind of successful, I think I am going to have to do quite a bit of learning on the subject as I think I am not fully understanding the facebook side of things! I think I am going to have to buy a book, but thanks anyway!
John




Theme © iAndrew 2016 - Forum software by © MyBB