ianlee-dev / facebook-java-api

Automatically exported from code.google.com/p/facebook-java-api
0 stars 0 forks source link

Problem In Authenticating a User for Desktop Application using HTTPClient. #261

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
I am trying to authenticate a Facebook user using HttpClient.As per Forums 
discussion, There should be a attribute named as "non_user_id_enc" either 
in Header or Response body. I am not able to find it.I have pasted a 
sample code please check.

FacebookXmlRestClient client = new FacebookXmlRestClient(apiKey, secret);
        String token = client.auth_createToken();
        System.out.println("token = " + token);

        HttpClient http = new HttpClient();
        http.setParams(new HttpClientParams());
        http.setState(new HttpState());

        GetMethod get = new GetMethod(loginUrl + "?api_key=" + apiKey +
"&v=3.0.1&auth_token=" + token);

        http.executeMethod(get);

        for (Header h : get.getResponseHeaders()) {
            System.out.println(h);
        }
        String nonUserId = null;
        Header setCookie = get.getResponseHeader("Set-Cookie");
       Header[] headers = get.getResponseHeaders();
       for (Header header : headers) {

           HeaderElement[] helements = header.getElements();
           for (HeaderElement e : helements) {
               if ("non_user_id".equals(e.getName())) {
                   nonUserId = e.getValue();
                   System.out.println
("----------------------------------------" + nonUserId);
                   break;
               }
           }   

    }
        /*HeaderElement[] helements = setCookie.getElements();
        for (HeaderElement e : helements) {
            if ("non_user_id".equals(e.getName())) {
                nonUserId = e.getValue();
                System.out.println
("----------------------------------------" + nonUserId);
                break;
            }
        }   */

        BufferedReader in = new BufferedReader(new InputStreamReader
(get.getResponseBodyAsStream()));
        String inputLine;
                    while ((inputLine = in.readLine()) != null) 
                        System.out.println(inputLine);
                    in.close();

What is the expected output? What do you see instead?
There should be an attribute named as "non_user_id_enc".

What version of the product are you using? On what operating system?
Window XP

Please provide any additional information below.

Original issue reported on code.google.com by sumittya...@gmail.com on 9 Nov 2009 at 6:46