Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 891303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:52:06+00:00 2026-05-15T13:52:06+00:00

I’m having problems trying to connect my website to Facebook. What I would like

  • 0

I’m having problems trying to connect my website to Facebook. What I would like it to do is allow users to augment their accounts by connecting them to Facebook (I do not need people to be able to login with Facebook, I am using OpenID instead). My website runs in the CodeIgniter framework.

What I will do is remove everything that I’ve tried and walk you through my steps up until it stops working.

Step 1: Set up the JavaScript SDK and XFBML

First I add a reference to the FBML spec to my <html> tag:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" xml:lang="en" lang="en">

Then, after my <body> tag, I add:

<script src="http://static.new.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>

Now here comes the first problem I had but have now solved. The problem was that the docs for the JavaScript SDK say that the FB.init() method requires the appId as a parameter, but this turned out to be incorrect. I needed to pass my apiKey instead. So this is the code that I ended up with, that goes before my </body> tag:

<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
    FB.init({
        apiKey  : '<?php echo $this->config->item('facebook_api_key'); ?>',
        status : true,
        cookie : true,
        xfbml  : true
    });

</script>

Now I can add XFBML entities to my pages, such as <fb:login-button></fb:login-button> which works just as expected. I click it and it pops up a box asking if I want to allow my website to access my Facebook profile. I say yes, and then if I check my Application Settings in Facebook, I can see that my website has been added.

So this step works fine.

Step 2: Set up the PHP library

Okay, so now I need to add the PHP library. So a quick google search for ‘codeigniter facebook library’ reveals Elliot Haughin’s library. I download the files, put them all in the right places then get to work on loading the library.

Now the current problem occurs. I add the following code (taken from the example given with the library) to my controller constructor so that it happens on every page:

$this->load->library('facebook_connect');
$this->data['fb_user'] = $this->facebook_connect->user;
$this->data['fb_userid'] = $this->facebook_connect->user_id;

But if I do print_r($this->data['fb_user']); I get nothing. Ever. Whether I’m logged into facebook, logged out, logged in and added my site to my profile, etc. etc. etc. The user and user_id are never set. I don’t get any errors though.

As far as I’m aware, the values are supposed to be set so that I know whether the person browsing my site is logged into their facebook account. If they are, I can see if they’ve allowed my application. If they’ve allowed it, I can let them disconnect from my site, if not, I can let them connect. But I can’t do anything if these variables aren’t populated.

I’ve tried poking around inside the source of the library, but I really can’t get my head around it. And I’m hoping that the actual solution for this won’t involve hacking the library apart. I’d expect a CodeIgniter specific library to work.

Any ideas?

Thanks a lot. 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T13:52:07+00:00Added an answer on May 15, 2026 at 1:52 pm

    Try this Facebook Library by Danny Tran hosted on Github. Works wonders and is fairly easy to get set-up.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.