Servage Magazine

Information about YOUR hosting company – where we give you a clear picture of what we think and do!

Using the Facebook PHP API

Friday, October 26th, 2012 by Servage

The world of social networks is really evolving around Facebook – good or bad – the truth is that you need to realize that importance, and use it to your advantage. Facebook apps are one great way of interactive with users in a custom way – which could give your project or product an advantage over the simple add. Getting starting with Facebook apps may seem overwhelming, but it’s really quite simple. They have a eel;-documented API which allows for lots of interaction.

You need to have the Facebook API downloaded and enclosed with your website. In this case it’s located in a subfolder called “php”. Your app’s index.php file could look like this simple setup:

require_once( "php/facebook.php" );
$api_key = "Api Key";
$secret = "Secret";

Next you need to instantiate a Facebook API object, so we can work with the available methods.

$facebook = new Facebook( $api_key, $secret );
$user_id = $facebook->require_login();

Whoever visits your app, will trigger a population of $user_id with the proper value. Using FBML you can get further info, like the user’s name.

echo "Current logged in as <fb:name uid=\"$user_id\" />";

So, working with the Facebook API is pretty simple and straightforward. You can learn a lot more on the developer pages here.

Using the Facebook PHP API, 4.0 out of 5 based on 4 ratings
Categories: Software & Webapps


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

No comments yet (leave a comment)

You are welcome to initiate a conversation about this blog entry.

Leave a comment

You must be logged in to post a comment.