Hello,
I’ve been working on a Facebook package for a few days now and I thought I’d post it here so you can check it out.
Currently it consists of a library, a helper and a config file. It also includes a sample controller and view.
The documentation for this library is located in the facebook_demo view and the it is as simple as:
$this->facebook->call("get", "me");to call call the Facebook Graph API, and as simple as:
$this->facebook->call("post", "me/feed", array("message" => "This is a message from the CodeIgniter Facebook Package"));to POST or GET parameters to the Graph API. It also supports the uploading of media to Facebook like this:
$image = "@".realpath(BASEPATH."../image.jpg"); // This locates a JPEG located in the root directory of your CodeIgniter setup (where your index.php file is located)
$this->facebook->call("post", "me/photos", array("source" => $image, "message" => "This is an image uploaded from the CodeIgniter Facebook Package"));You can also easily add Open Graph meta tags to your view files by creating an array like this:
$data['meta'] = array("og:title" => "CodeIgniter Facebook Library", "og:type" => "website", "og:description" => "A Facebook library for CodeIgniter that allows you to make calls to the Facebook Graph API and easily integrate the meta tags for the Open Graph protocol.", "fb:app_id" => $this->config->item("facebook_app_id"));
$this->load->view('facebook_demo', $data);and parse the array into meta tags in your view by placing this line of code in the <head> of your HTML:
<?=facebook_meta($meta)?>
The best way to keep this package up-to-date is to create a “b2tm” folder inside your “third_party” folder, with a “facebook” folder in there with the contents of the entire package, you can then replace the code when a new release is available, either through “git pull” or simply copy the updated files into there. You can then add the package path using:
$this->load->add_package_path(APPPATH.'third_party/b2tm/facebook/application');
You can download this package from this GitHub repository: https://github.com/b2tm/CodeIgniter-Facebook-Package
Please let me know if you find any bugs or would like to request any features.
Hope you like it! 😊