Tutorials
Facebook DevelopmentIf 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:
![]()
Once you're there, find the link to the Resources page:

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:

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

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:

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:

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:

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:

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.
|
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(); } } |