Sunday 20 January 2013

Getting Facebook Contacts in 4 Simple Steps


Here I am giving you simple demonstration about how to import contacts from Facebook.

Step 1: Create a facebook app at https://developers.facebook.com/
 I have created a try app which I am using to get my FB contacts:

client_id=345255442153376
Client_Secret=dba2c658b768480a616d7fc7f198e725  &
redirect_uri=http://localhost:6209/default.aspx


After completing step 1 go to step 2.


Step 2:  Browse to the below url in browser window:


it will ask for permissions click Allow Button:
This will give u a window like below which is having code=some_code like query string in browser window we need to use this code further.



We need to use code 

(code=AQDAklJNfyMiZvOSUZBCHgw0KTwIQoJRPoN0tTJ90CJL6Xb547wHRaKlem81WWQsg_59o-OI9-VpoF7O0UQ09wAqn6AUV0QX7CYreYvlIQjPS4D5ptoUxJep1hJ5CGgo9zCayyaS5W8emja39bUYas4SvdsR9vLLVnGOCDDGgmvrO4e0enIh5nXchXbb3JxJw6EDz4Cqf2OSzunCLLWEZxux#_=)  in next step.

Step3 :  Now browse to the url in browser window:


Note: we need to use same code which we have retrieved in step2.    
                               
This step will give you an access token as query string. Something likes this:


access_token= AAACEdEose0cBAM3Dbomr0wlNsMySIa8QGavZB15onOZAGZBGi8bPLHLOZCl6HXVCTNO17sPLArfThihlAbosDlyfbFJyZAOh2EHVbWZB3WbKxAX1o5E9Gi

Now we need to use this access i to get contacts in next step.

Step 4: Browse to the below url and it will give u contacts in Json format.

https://graph.facebook.com/me?access_token=AAACEdEose0cBAM3Dbomr0wlNsMySIa8QGavZB15onOZAGZBGi8bPLHLOZCl6HXVCTNO17sPLArfThihlAbosDlyfbFJyZAOh2EHVbWZB3WbKxAX1o5E9Gi/me/friends

Note: we need to use same access token which we have retrieved in step3. 
For implementing above code you need to use asp.net HttpRequest and HttpResponse Objects.

For more go to:

No comments:

Post a Comment