views:

46

answers:

1

I am developing facebook application. In this application, I use java api provided by Google and the application is based on web.

I have the facebook_api_key and facebook_secrete, but how to get the sessionKey?

This code is not web-based:

FacebookJsonRestClient client = new FacebookJsonRestClient(Test.API_KEY, Test.SECRET);
String token = client.auth_createToken();
String url = "http://www.facebook.com/login.php?api_key=";
url += Test.API_KEY;
url += "&v=1.0";
url += "&auth_token=";
url += token;
String strCommand = "C:/Program Files/Internet Explorer/IEXPLORE.EXE ";
        strCommand += url;
Runtime.getRuntime().exec(strCommand);
// wait until the login process is completed
// fetch session key
String session = client.auth_getSession(token, true);
......

I want to change it to web-based one.

Pls help me. thanks

A: 

Why can't you try this way:

String sessionKey = request.getParameter(FacebookParam.SESSION_KEY.toString());

FacebookXmlRestClient client = new FacebookXmlRestClient(FB_API_KEY, FB_SECRET_KEY, sessionKey);

I also suggest the FaceBook Developer Forum Dicussion and an article describe about generating session keys. I thought it could be helpful to you..

venJava
it is only desk-based application. I cant use what u said in the Servlet!!!!!
ZHAO Xiaojian