How to make sample facebook application with firefox add ons RestClient
Note: If you have any doubt about the Facebook application technology ( OAuth protocols) please refer this link and also this link teaches, how to create facebook application dashboard on your facebook account.
STEP 1 ( Authorization code request )
In order to obtain the authorization code from Facebook, we have to send a HTTP GET request to the Authorize Endpoint of Facebook, which is https://www.facebook.com/dialog/oauth . Along with the request, you should have several parameters which are described below.
Parameter Name
|
Description
|
Sample Value
|
Response_type
|
What will you get back from HTTP GET request
|
code
|
Client_id
|
This is app id given by facebook
|
1746117745691626
|
Redirect_url
|
Your app domain, which is given by you. Also it is called as redirection endpoint. It defined in facebook login setting.
|
|
scope
|
What permission you Need to get from users. If you want more information visit this page
|
public_profile user_posts user_friends user_photos
|
if anyone clicks this link we can get their scopes.
USER CONSENT PAGE
if owner click above blue button client application will get the authorization code from authorization server.
Authorization code:
we should make this request on POST methods because this request has the user id and secret. so we have to send those things over the HTTP header. this header value should be encoded and also we have to send the following parameter in the body of the HTTP post request.
Parameter Name
|
Description
|
Sample Value
|
Grant_type
|
Authorization code
|
authorization_code
|
Client_id
|
This is app id given by facebook
|
1746117745691626
|
Redirect_url
|
Your app domain, which is given by you. Also, it is called as redirection endpoint. It defined in facebook login setting.
|
|
code
|
Which is taken from the previous step
|
AQDfw1CLKYt-
TuoGq1m8oChT8LHbWxz01zWgmkdxRRodgJua5TbEI _HMYHaL -64LzpL56KCfNz12Yt3WXlIeep4t0Mc9VCQ9- i7SPEIk7gPSmzy4m3fpNawmQCvtw5FEU6pM0ON8EMDv -6Vp1-ty907V4Cnu5sp__QTuJ2c9wz9Co1GIrOO3qEF 2Vu9ruaKkMhZDSNAa0fgbd-5PLiivkN75nr7nsFCHl JEkadBfkIVddJTqd4AH7 zc8KFXWta87KA3Kt3Taz7h0lTJff3wQuciWRqhvytOp E90snQPyNJkitpaQeX3VSLHeLd77QOKMNUGw2TnMr6B9d-Y6AZx1M-Of6MeQmeogsyhE0QzihAI6eQ#_=_ |
- Header
- name: Authorization
- value: Basic "AppID:AppSecret" this should be base64 encode
( - 1746117745691626: b91d622fd71c99430be01d38e9ec0c76)
- Body
- grrant_type: authorization_code
- redirect_url: http://localhost:8080/facebookapp/callback
- Client_id: 1746117745691626
- Code:AQDfw1CLKYt-TuoGq1m8oChT8LHbWxz01zWgmkdxRRodgJua5TbEI_HMYHaL-64LzpL56KCfNz12Yt3WXlIeep4t0Mc9VCQ9-i7SPEIk7gPSmzy4m3fpNawmQCvtw5FEU6pM0ON8EMDv-6Vp1-ty907V4Cnu5sp__QTuJ2c9wz9Co1GIrOO3qEF2Vu9ruaKkMhZDSNAa0fgbd-5PLiivkN75nr7nsFCHlJEkadBfkIVddJTqd4AH7zc8KFXWta87KA3Kt3Taz7h0lTJff3wQuciWRqhvytOpE90snQPyNJkitpaQeX3VSLHeLd77QOKMNUGw2TnMr6B9d-Y6AZx1M-Of6MeQmeogsyhE0QzihAI6eQ#_=_
- To: https://graph.facebook.com/oauth/access_token
SAMPLE HTTP REQUEST
"grant_type=authorization_code&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Ffacebookapp%2Fcallback&client_id=183994178774345&code=AQDfw1CLKYt-TuoGq1m8oChT8LHbWxz01zWgmkdxRRodgJua5TbEI_HMYHaL-64LzpL56KCfNz12Yt3WXlIeep4t0Mc9VCQ9-i7SPEIk7gPSmzy4m3fpNawmQCvtw5FEU6pM0ON8EMDv-6Vp1-ty907V4Cnu5sp__QTuJ2c9wz9Co1GIrOO3qEF2Vu9ruaKkMhZDSNAa0fgbd-5PLiivkN75nr7nsFCHlJEkadBfkIVddJTqd4AH7zc8KFXWta87KA3Kt3Taz7h0lTJff3wQuciWRqhvytOpE90snQPyNJkitpaQeX3VSLHeLd77QOKMNUGw2TnMr6B9d-Y6AZx1M-Of6MeQmeogsyhE0QzihAI6eQ#_=_"
Now that we have received the OAuth access token from facebook, in all the requests we make to the Facebook API, we need to include it as a HTTP header.
Header
- name: Authorization
- value: Bearer and access token
receiving information from Facebook
- Timeline post
get the user id
For invoking many operations like retrieving user’s photos, albums etc. We need to know the user’s Facebook ID. For that, we can send a HTTP GET request to the URL https://graph.facebook.com/v2.8/me?fields=id which would return the ID in a JSON response.
user friend list
https://graph.facebook.com/v2.8/<FB User ID>/taggable_friends
before getting the photo, we should know album id
Comments
Post a Comment