dangtranduc / facebook-java-api

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

unknown host exception api.facebook.com #358

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Copy the given code in a java application and run it
2. public class ABCD {

    private static void getUserID(String email, String password){
        String session = null;
        try {

            HttpClient http = new HttpClient();

            http.getHostConfiguration().setHost("www.facebook.com");
            String api_key = "194133440688156";
            String secret = "d06cf77b573fefe45c388c5c577b02ba";
//              if (Desktop.isDesktopSupported()) {
//        Desktop desktop = Desktop.getDesktop();
//        desktop.isSupported(Desktop.Action.OPEN);
//                  System.out.println("Ffaff"+Desktop.isDesktopSupported());
//            }
            FacebookJaxbRestClient client = new FacebookJaxbRestClient(api_key, secret);
                System.out.println("====>"+client.auth_createToken());
                System.out.println("Client "+client.getCacheSessionKey());

            String token = client.auth_createToken();
            System.out.println(" :::::::"+token);
            System.out.println(" :::::::::: "+token);
            PostMethod post = new PostMethod("/login.php?");

            post.addParameter("api_key", api_key);

            post.addParameter("email", email);
            post.addParameter("pass", password);

            int postStatus = http.executeMethod(post);
                System.out.println("url : " + post.getURI());
            System.out.println("Response : " + postStatus);
            for (Header h : post.getResponseHeaders()) {
                System.out.println(h);
            }
            session = client.auth_getSession(token); // Here I am getting error
            System.out.println("Session string: " + session);
            long userid = client.users_getLoggedInUser();
            //System.out.println("User Id is : " + userid);*/
        } catch (FacebookException fe) {

            fe.printStackTrace();

        }catch(Exception e){
            e.printStackTrace();
        }
    }

    public static void main(String args[])
    {
     ABCD obj=new ABCD();
     obj.getUserID("luckysingh0112@gmail.com", "JaiAArti");
    }

}
3.

What is the expected output? What do you see instead?
It wil print the session id

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

Please provide any additional information below.
please help me!!

Original issue reported on code.google.com by jds.c...@gmail.com on 23 Feb 2012 at 11:26