View Facebook API Code

Before going to proceed further, following liberary must be available in your class path,
  • activation-1.1.jar
  • commons-lang-2.2.jar
  • commons-logging-1.1.1.jar
  • facebook-java-api-3.0.2.jar
  • facebook-java-api-annotation-processor-3.0.2.jar
  • facebook-java-api-schema-3.0.2.jar
  • jaxb-api-2.1.jar
  • jaxb-impl-2.1.9.jar
  • json-20080701.jar
  • restfb-1.6.12.jar
  • runtime-
  • stax-api-1.0-2.jar
We are using following two API to communicate with Facebook.
  1. Facebook API
  2. RestFB API
Create file under src directory in your project. 
create new servlet file which handles incoming and outgoing request from our application. We required only file to handle all the request. No need to worry about rest of the thing right now, just enjoy programming to integrate Facebook API.  As you can see from the code, when the servlet called first time at that time code was null so it comes under the else part and redirect to facebook to validate their credential. 

once facebook gets approved it will return back with either code or token, depend upon our configuration.We have provided redirect_uri parameter to facebook to indicate that response came from facebook will be proceed by this servlet. 

in our case both servlet are same. Means we are using the same servlet to send a request to facebook and proceed response from facebook. Once we received code/token, one can send a request to get an access token of your application, Access token play very important role for communicating. 

Note : I have changed my API_KEY & SECRET_KEY so you can changed with yours. If you don't know how to get API & Secret key then visit this post Steps to FBI API. Before going to start with Facebook integration, Please refer documentation first that would be easy to understand code as well as flow.

posted under , |


Quyet Bui said...

thank you very much

Post a Comment

Please provide your valuable comment.

Newer Post Older Post Home


Powered by Blogger.


Custom Search