Credeti ca e foarte greu?
Cititi cei 12 pasi descrisi de Kumar Chetan Sharma pe blog-ul LAMP Web Development Blog.
- Sign up for Facebook if you don’t have an account. If you can’t do this simple thing do not read further.
- Go to Account > Applications and add Facebook Developer application.
- Go to the app page, locate and click the “Set up new application” button.
- Follow the instructions which let you name your app and set other things.
- Dont bother if you dont understand anything in the forms. Fill what you understand and just pay attention to following fields:
a) Under Canvas > Canvas Page URL, create a Canvas URL which will be your app’s URL on Facebook, for example “my-hello-world-app”
b) Under Canvas > Canvas Callback URL, this will be URL where we will host our Facebook app, so if I host my app on kumarchetan.com, the URL will be http://www.kumarchetan.com/, easy
c) Under Canvas > Canvas Settings > Render Method, choose FBML.
- Download the client library from here: http://svn.facebook.com/svnroot/platform/clients/packages/facebook-platform.tar.gz
- Extract the library on your local machine and you will end with a folder with two sub folders. We will be using folder named “php”.
- Open “index.php” in your choice of editor and you will see following code
// Copyright 2007 Facebook Corp. All Rights Reserved.
// Application: Ye app puri philmy hai
// File: 'index.php'
// This is a sample skeleton for your application.
//Your API key
$appapikey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
//and your secret
$appsecret = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyy';
$facebook = new Facebook($appapikey, $appsecret);
// Login is required
$user_id = $facebook->require_login();
Delete everything after this code,
we will simply say “Hello dear” with user name in our app.
- Add following
echo 'Hello <fb:name uid="', $user_id, '" firstnameonly="true" />!';
- Upload all the files in php folder to the server which you provided in Canvas Callback URL.
- Go to URL http://app.facebook.com/my-hello-world-app, remember “my-hello-world-app” was Canvas URL for our app.
- Voila!!! Your app is ready!