Tag Archives: facebook

Installing Facebook PHP SDK as a Library in CodeIgniter

So I searched all over the net and couldn’t really find the answer to a simple question… how do you integrate Facebook’s PHP SDK AS IS as a Library in CodeIgniter?

There are a lot of great libraries out there that add their own functionality as well as integrate, but it’s not something I was looking to do really.. the default functionality was enough.

Anyway here’s how to do this. first go here:
http://github.com/facebook/php-sdk/

download the latest version and upload the 3 files facebook.php base_facebook.php and fb_ca_chain_bundle.crt to your application/libraries/ directory.

Now rename facebook.php to Facebook.php

Now create a file in your application/config/ folder called: facebook.php

in this file you should have the following:

< ?php  
if ( ! defined('BASEPATH')) exit('No direct script access allowed'); 
$config['appId']		= 'your_app_id'; 
$config['secret']	= 'your_app_secret'; 
$config['canvas']	= true; 

Ok now save that file and open up in that same dir (application/config/) open: autoload.php and then look for: $autoload['libraries']

Add to this array ‘facebook’ so it should look like this:

$autoload['libraries'] = array('database','session','facebook');

Do keep in mind that in this case I am also loading the database and session libraries.

Once you do this, you can simply call $this->facebook to access your Facebook Library Class.

Note: DO NOT add facebook to $autoload['config'] = array();

I made this mistake and took me some time trying to figure out why it wasn’t working properly.

accidentally locked Adium out of facebook via account security (the fix)

For as long as I have used Adium, I enjoyed being able to add my Facebook chat account to it so that I can use one central place for all things chat. A few months ago, I logged into my Facebook Account Security screen and noticed there were some logins from an unknown source. So naturally I went in and clicked “End Activity” (big mistake!) turns out that activity was Adium! so thus I permanently locked my self out of being able to log in to Facebook via Adium.. keep in mind that this was using the default Facebook account type in Adium account type list (it has a Facebook chat connect plugin).

Then I started the search online.. looking for a way to remove a device that I accidentally blocked. Turns out, there is no way to do it!! I kept doing my research and then found out today that you can actually add access to Facebook chat using Jabber! Boy was this a life saver! I can now connect again to facebook chat using Adium.
The visual how to:

where you see the words blurred out, you type in your Facebook username. i.e. the one you set up a long time ago at http://www.facebook.com/username

People looking for ways to hack Facebook like buttons?

I was looking at my google analytics data for this blog the other day and noticed there were a decent amount of hits for the search string ‘Facebook like hack’ and similar search strings. I was getting these hits to my blog post about how to add the Facebook like button to your IPB forum posts via bbcode and a little creative JavaScript modification.

When searching for the term, I found only one other article about avoiding Facebook like button hacks designed to steal personal info, but not much else. Heh, maybe that’s why i am getting so many hits on this search.

Seems there might be an increase on hacking attempts? Or maybe it’s just that I have risen in rank for that search term (or both). Either way, it will be interesting to see if Facebook does get a problem with a Facebook like button hack (though I hope it doesn’t happen heh).

Facebook Like button hack for IPB Board

Ok so I was trying to figure out how to add a Facebook like button to an IPB Board system, and it was not as easy as it should have been!

turns out, you need valid license to download their Facebook like module, and for what ever reason I couldn’t make the edits directly to the theme files to include the JavaScript and required div.

So this is what i did.

first I created a bbcode tag so that i could do this:

[fb]http://URL-to-like[/fb]

and it print out the right code of:

<fb:like href="http://URL-to-like"></fb:like>

that was easy. just add a bbcode tag in the bbcode administration page.
Name the tag Facebook Like Button
Create a tag [fb]
define the replacement as:

<fb:like href="{content}"></fb:like>

note: that %7Bcontent%7D above is actually {content}
for what ever reason my code parser is changing it.

Leave all the other attributes defaulted.

Then came the annoying part… how to add the required JavaScript and element to the post pages.

Solution? yes! find the JavaScript file: /public/js/ips.topic.js
and then at the very bottom of the file add the following code:

function loadFacebookMod() {
	var div = document.createElement('div');
	div.id = 'fb-root';
	if (document.body.firstChild){
		document.body.insertBefore(div, document.body.firstChild);
	} else {
		document.body.appendChild(div);
	}
	window.fbAsyncInit = function() {
	  FB.init({appId: 'your facebook app id', status: true, cookie: true,
	           xfbml: true});
	};
	(function() {
	  var e = document.createElement('script'); e.async = true;
	  e.src = document.location.protocol +
	    '//connect.facebook.net/en_US/all.js';
	  document.getElementById('fb-root').appendChild(e);
	}());
}
window.onload = loadFacebookMod;

what’s happening here is that first, you are creating a function that creates the

<div id="fb-root:"></div>

needed by the Facebook js to work, appends it to right after the opening body tag, and then we load the Facebook JavaScript. After we create that function, we tell it to load the function when the page is done loading (to make sure that it finds the body tag no problem).

Now am sure there is a better way to do this… but I couldn’t find it, so, this is my solution.