I want to share the source code first for the busy guys. Source code for Facebook connect for Codeigniter
Hope you have already went through my tutorial on the Facebook Connect implementation in Codeigniter. This part comes after connecting the user to your website.
Once user is authenticated with the required access tokens, you can call any methods mentioned in the Graph API at http://developers.facebook.com/docs/reference/api/. Here I will explain just one method from it to post to the user’s wall on Facebook.
In the previous tutorial we have created a Facebook connect library. Add the following method to the library it will do the trick. If user is not logged in or has no access to post then the function will return false.
function post_to_wall($message,$link="",$photourl="")
{
if($this->fbSession)
{
$param = array('message'=>$message,'cb' => '');
if($photourl!="")
{
$param["picture"] = $photourl;
}
if($link!="")
$param["link"] = $link;
$posts = $this->fb->api('/me/feed','post',$param);
return TRUE;
}
else
{
return FALSE;
}
}
Same way if you want to get user’s wall posts pass “me/home” to the fb->api method in the above functions.
Learned something? For complete reference of the available functions refer the Facebook Graph API.

I have got this error, when i used this code.
“Fatal error: Call to a member function api() on a non-object in /application/libraries/fb_connect.php on line 56″
Anyone can help me to resolve this error.
Did you already went through my previous post http://www.betterhelpworld.com/codeigniter/how-to-use-facebook-php-sdk-v-3-0-0-with-codeigniter?
Could you please share the exact code so that I can help?
Hi,
I have download your library. But not getting how to use it. ?? please let me know
Please go through http://www.betterhelpworld.com/codeigniter/how-to-use-facebook-php-sdk-v-3-0-0-with-codeigniter first.
I tried out your tutorial for facebook connect and get redirected to facebook with an error page displayed
Hi, great tutorial!
I have a problem, i’ve downloaded your project and merge with mine.
Everything seems to work OK, when i enter to mydomain.com/user/
It redirects me to facebook, and ask me for the app’s permission.
I click “Allow” and it redirects me to mydomain.com/facebook?state=………..
But, i don’t know why, at the facebook method:
if (!$this->fb_connect->user_id) {
echo ‘not allowed’;
}else{
echo ‘allowed’;
}
it shows “not allowed”, but i allowed the application.
My facebook config is ok, but i don’t know if i have to configure something on my facebook application.
I’ll be very gratefull if you can help me.
Im sorry, at the sixth line, i wanted to say:
I click “Allow” and it redirects me to mydomain.com/user/facebook?state=………..
i’ve missed the controller at the url
Sorry for the late reply. Have you solved the problem already?
Hello msnisha,
I have same problem with Ariel also, after clicked Allow, facebook redirected me to mydomain.com/user/facebook?state=…….
How do i solve this? it doesn’t even print_r($fb_usr)
Thanks!
I have got this error, when i used this code. Fatal error: Call to a member funicton api() on a non-object in /application/libraries/fb_connect.php on line 56 Anyone can help me to resolve this error.
thank you very much! your source is what i want!
but i found some errors at post_to_wall function.
so, i modified like this,
function post_to_wall($message,$link=”",$photourl=”")
{
if($this->user_id != FALSE)
{
$param = array(‘message’=>$message,’cb’ => ”);
if($photourl!=”")
$param["picture"] = $photourl;
if($link!=”")
$param["link"] = $link;
$posts = $this->api(‘/me/feed’,'post’,$param);
return TRUE;
}
else
{
return FALSE;
}
}
thanks for your help!