Exforsys.com
 

Sponsored Links

 

Facebook Development Tutorials

 
Home Tutorials Facebook Development
 

Obtaining the Facebook Client Libraries

 

If you're going to build a Facebook application, then you're going to need access to the Facebook API, and to do that, you'll have to download the client libraries onto your server. In order to do this, you'll need to go to the developers' page—remember that you can use the URL http://developers.facebook.com, or use the link given at the bottom of each Facebook page:



fb013.png


Once you're there, find the link to the Resources page:


fb014.png


Or, go directly to xhttp://developers.facebook.com/resources.php.


When you're in the Resources page, you can click on the library that you want to use. In this instance, we're going to be using the PHP (4 and 5) Client Library:


fb015.png


Of course, if you want to know more about a library, then just click on Description of contents:


fb016.png


So far, everything we've looked at will be the same whether you are using Windows or Linux on your server, and that's true for most of what we'll be doing. However, this is one instance when what you do will depend on your server's  operating system.


The file that you are going to download is compressed, but not in a form normally used in Windows (you'll notice that they have a tar.gz suffix). So, you'll need to obtain software that can uncompress the files for you. A quick Google search will find a lot of them, but a suitable one is available from http://www.winace.com" target="_blank" rel="nofollow", although you'll find that it does display some annoying pop-ups, so you may want to delete it once you're finished. However, once you've installed WinAce, you'll be able to uncompress the libraries:


fb017.png


If, on the other hand, you're using Linux, then you'll be able to uncompress the files quite readily. If you prefer to use a GUI type interface, then there is a software, which you can use, called Ark:


fb018.png


However, if you prefer to use the command line (as I do), then you can both download and uncompress the files very easily:


cd /srv/www
wget http://developers.facebook.com/clientlibs/facebook-platform.tar.
gz
tar -xvzf facebook-platform.tar.gz


Of course, you'll need to change /srv/www to a suitable directory on your own server, one that you can write to. And in case you're not used to the commands, cd moves you to the directory, wget downloads the library, and tar uncompresses it. If you type the commands on the command line, then you'll see something like this:


fb019.png


At the moment, it doesn't actually matter where you place the libraries, but regardless of whether you're using Windows or Linux, you should end up with a set of PHP files somewhere on your server:


fb020.png


And now, you are ready to move on to telling Facebook about the application that you're going to be creating.



So far, we've spent a bit of time looking at the Facebook Platform—you have learned where it fits in with any application that you build, and you have learned how to experiment with the Platform's functionality, without even having an application. In Chapter 2, you'll learn how to create that first application.


However, before you create your own application, you're going to have to add another application—Facebook's Developer.



Read Next: Adding Facebook Developer Application



 

 

Comments


premal said:

  Hi,
I am facing a problem in following code. I want my application and login screen should open in same browser window. Using this code It always opens in new window. Will anybody please tell me how to achieve it?
Again the code in if/else block in the function Init() never gets executed. It directly goes to session.login() and opens new window.

Please help me.

public function Init():void
{
session = new FacebookSessionUtil("MY_API_KEY","MY_SECRET_KEY",loaderInfo);
session.addEventListener(FacebookEvent.CONNECT, handle_Connect);
fbook=session.facebook;
trace("initial login");
if(loaderInfo.parameters.fb_sig_added == true)
{
session.verifySession();
}
else if(loaderInfo.parameters.fb_sig_added == false)
{
navigateToURL(new URLRequest("http://www.facebook.com/login.php?api_key=" +loaderInfo.parameters.fb_sig_api_key), "_top");
}
else{
session.login();
onConfirmLogin();
}
}

public function handle_Connect(event:FacebookEvent):void
{
trace("handle_Connect");
var call1:FacebookCall = fbook.post(new GetInfo([fbook.uid],[GetInfoFieldValues.ALL_VALUES]));
call1.addEventListener(FacebookEvent.COMPLETE,handle_getinfoComplete);
}
public function onConfirmLogin():void
{
trace("onConfirmLogin");
session.validateLogin();
}
public function handle_getinfoComplete(event:FacebookEvent):void
{
trace("handle_getinfoComplete");
user=(event.data as GetInfoData).userCollection.getItemAt(0) as FacebookUser;
if( user == null )
{
trace("handle_getinfoComplete,onConfirmLogin");
onConfirmLogin();
}
else
{
trace("hi",user.first_name+" "+user.last_name);

StartGame();
}

}
March 8, 2010, 7:31 am

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2010 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape