Pages

Thursday 5 July 2012

This tutorial will explain how to create a facebook application using Graph api and PHP.For those who are new to Facebook platform you need to learn the basics of Graph api.We are about to build a facebook application you can see a demo here
facebook-platform
facebook-platform
This tutorial will use PHP code-See PHP tutorials on our site
Introduction to Facebook platform
Facebook allows developers to build applications using facebook platform which has
FBML – Facebook Markup language
FQL – Facebook Query Language
FQJS – Facebook JavaScript
These are basically derived from standard HTML,SQL and javascript to suit the facebook environment.Other than this you need to knoe how the facebook environment is built.Each and every element in facebook is easily accessible from “Graph – API ” which was improved version of REST api which was used previously.
Suppose you want to access the profile picture of a person you can simply call this API
http://graph.facebook.com/mjeyaganesh/picture
This url simply returns the profile picture of the my facebook account.All you need is the name or UID of the person, in this case you can access my profile picture using my UID also.The power of Graph Api is self explained,you dont need to do complex program to do this easy task.
You can easily access information like name,age,gender,location,friends etc I would recommend you to read Graph api documentation.Keep in mind that not all information is accessible you need to get a permission or access token from the user to access it.
Step 1: Create a new application
Our first step to create a facebook application is go to http://www.facebook.com/developers/ and click “set up new application “.Give your application a name and agree the terms click submit.
facebook application
facebook application
Step 2: Fill in the details of the application
facebook application
You will be directed to this page to fill up the essential details of the application.
Step 3: Fill in the facebook integration
Every application has application ID,application secret key and api key unique to every application.You need to fill in the details like canvas page ,canvas url etc.
facebook application
Note: Kindly use “https” in the secure canvas url.
The canvas page is your facebook application url,you can see your application in that URL.
Canvas URL- Each application is just a simple PHP page which will be hosted on your server and the canvas page simply renders the application inside facebook.In this case I have hosted my files at “www.devlup.com/fb/”
See about canvas
Application architecture
Step 4 : Complete registration
For now click save changes [you can edit details later ]
Step 5 : Download client library
To get started in programming you need the client library.In this case we are developing in PHP hence download php client library.There are other client libraries for Javascript,iOS,android sdk’s [ see here] .
PHP SDK
Step 6 :Upload the library
Create a folder in your server and extract the library files there,The “src” folder has facebook.php which will serve as the client library.

Step 7 : Set defaults
  1. < ?php include_once "src/facebook.php"; $app_id = 'YOUR APP ID'; $application_secret = 'YOUR APP SECRET'; $facebook = new Facebook(array( 'appId' => $app_id,
  2. 'secret' => $application_secret,
  3. 'cookie' => true, // enable optional cookie support
  4. ));
Step 8: code
Check whether the user is logged into facebook before loading the application.If the user is not logged in show the $loginurl
  1. if ($facebook->getSession())
  2. {
  3. $user = $facebook->getUser();
  4. }
  5. else
  6. {
  7. $loginUrl = "https://graph.facebook.com/oauth/authorize?type=user_agent&display=page&client_id=APPID
  8. &redirect_uri=http://apps.facebook.com/CANVAS URL/
  9. &scope=user_photos";
  10. echo '';
  11. }
Step 9 : Fetch details
The concept of this application is to display all the profile pictures of your friends in single page
First get the UID of the current user loggin by calling the function getuser()
  1. $uid = $facebook->getUser(); //get the UID of the current user
  2. $me = $facebook->api('/me/friends'); // access all the information of friends
  3. // $me has the JSON detail of all the facebook friends of the current user
  4. echo " Friends collage";
  5. foreach($me['data'] as $frns)
  6. {
  7. // Display the picture of friends one by one
  8. echo "<img title="\"".$frns['name']."\"/" alt="" src="\">";
  9. }
Step 10 : Complete coding
  1. < ?php
  2. include_once "src/facebook.php";
  3. $app_id = 'APPID';
  4. $application_secret = 'APP SECRET';
  5. $facebook = new Facebook(array(
  6. 'appId' => $app_id,
  7. 'secret' => $application_secret,
  8. 'cookie' => true, // enable optional cookie support
  9. ));
  10. if ($facebook->getSession()) {
  11. $user = $facebook->getUser();
  12. $uid = $facebook->getUser();
  13. $me = $facebook->api('/me/friends');
  14. echo "Total friends".sizeof($me['data'])."";
  15. echo " Friends collage
  16. ";
  17. foreach($me['data'] as $frns)
  18. {
  19. echo "<img title="\"".$frns['name']."\"/" src="\"https://graph.facebook.com/".$frns['id']."/picture\"">";
  20. }
  21. echo "
  22. By <a href='\"http://facebook.com/mjeyaganesh\"'><img title='\"Jeyaganesh\"/' src='\"https://graph.facebook.com/1147530774/picture\"'></a>";
  23. }
  24. else {
  25. $loginUrl = "https://graph.facebook.com/oauth/authorize?type=user_agent&display=page&client_id=APPID
  26. &redirect_uri=http://apps.facebook.com/CANVAS URL/
  27. &scope=user_photos";
  28. echo '<fb:redirect url="' . $loginUrl . '"></fb:redirect>';
  29. }
  30. ?>
After saving the file.Proceed to your canvas URl to see the demo of your application[http://apps.facebook.com/canvasurl] you can submit to facebook app directory after 10 people start using your application.
Step:11 Outcome
DEMO
Access permission for first time user

Tuesday 26 June 2012

AKUKAH YANG SEBENAR


Berkemungkinan Apa Yang Difikirkan



BISMILLAHHIROHMANIRROHIM
Aku bermohon keampunan kepadamu ya allah dan ku bermohon kepadamu pelindungan dari segala bisikan dan hasutan syaitan dan aku bermohon kepadamu ya allah lindungan diriku ini yang mana telah kau tempatkan aku didalam jasad yang aku tumpangi untuk aku menjalankan tanggungajawabku sebagai khalifah dibumi milikmu,agar aku memperoleh keberkatanmu untuk aku merasai ketenangan yang abadi di akhirat nanti...
SIAPA AKU?
siapa aku untuk seseorang yang mempunyai nama yang diberikan oleh ibu dan ayah kepada kita dan dibangku sekolah lagi kita telah ditanya oleh cikgu-cikgu disekolah untuk kita kenal siapa kita (siapa saya).adakah kita kenal diri kita siapa dan adakah kita tahu siapa kita atau siapa aku.contohnya adakah aku yang diberi nama polan sipolan?adakah aku yang mergelar suami,ibu,abang,kakak,adik,dan sebagainya.atau adakah siapa aku ini seorang yang berjawat tinggi,mempunyai wang yang banyak dan lain-lain lagi.adakah persoalan ini terjawab sehingga sekarang?dan kita sebagai mahkluk allah akan kita menjawab kita adalah hamba allah dimuka bumi ini.tetapi adakah kita hanya menjawab seperti itu?pada sesetengah manusia yang dipilih oleh Allah s.w.t akan kenal dan mengenali akan dirinya sebenar dan akan tahu jawapan SIAPA AKU untuk dirinya dan sukar untuk seseorang itu menceritakan atau memberitahu ataupun membayangkan pada seseorang itu akan mengenali SIAPA AKU...dan disini akan di saya rungkaikan kepada anda untuk anda kenali diri anda...


Related Posts Plugin for WordPress, Blogger...

mencari siapakah "AKU"

AKU adalah satu ayat yang sinonim kepada kita apabila kita berdoa kepada ALLAH s.w.t.dan jarang sekali dan sukar untuk kita terdengar apabila seseorang itu berdoa mengunakan ayat seperti (saya).istilah pengunaan ayat AKU ini adalah ayat yang amat mendalam buat diri seseorang yang jauh menusuk kejantung sekiranya mengunakan ayat AKU ini.
sabagai satu contoh:
sekiranya sahabat kita sedang memandu kereta dan kita menunggu sahabat kita di sebuah warung kopi misalnya...lalu kita ternampak sahabat kita dari simpang masuk kewarung kopi tersebut,apakah yang akan kita katakan didalam hati kita atau mulut kita."sipolan dah sampai dahhh..." atau "haaa..sampai pun sipolan ni" atau "tu sipolan dah sampai" benarkah kita akan berkata seperti ini?.apa yang kita katakan seperti ini adalah berdasarkan kepada sipolan yang menaiki kereta dan kita mengatakan dia telah sampai tetapi kata spontan yang kita luahkan menuju maksud kepada kenderaan yang dinaiki olehnya.
-bolehkah anda cuba membayangkan..andaikan kenderaan itu adalah jasad manusia dan orang yang memandu adalah rohaninya?
-sekiranya sipolan memandu kenderaan itu lalu berlaku kemalangan.apakah yang terjadi kepada kenderaan dan pemandu itu?adakah kenderaan yang terasa sakit atau pemandu itu yang terasa sakit?
-sekiranya kematian berlaku dimanakah kereta itu dibawa?benarkah dibawa ke bengkel kereta dan pemandunya dibawa(mayatnya)oleh pihak polis / pihak hospital?
-cuba anda alihkan keadaan kereta dan pemandu kepada diri kita jasad dan rohani kita.
-cuba kita mencubit peha kita.adakah terasa sakit?sudah pasti akan terasa sakit betulkan.
dan cuba kita mencubit peha orang yang telah meninggal dunia pula...?adakah akan terasa sakit..?bolehkah anda tolong jawabkan?mungkin anda berbelah bahagi untuk menjawab..samada sakit atau tidak.saya tolong jawabkan "tak sakit pon".percaya atau tidak dengan jawapan itu..?
mungkin anda kurang jelas dan masih sukar menjiwai keadaan seperti ini.saya akan jelaskan dengan lebih mendalam lagi..
Related Posts Plugin for WordPress, Blogger...