nourelhoudabenahmed / 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 #359

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 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("gfggf@gmail.com", "gfgg");
    }

}
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

GoogleCodeExporter commented 8 years ago
Please send me the solution at jds.cdac@gmail.com "how can we authenticate in 
facebook using java desktop application.That means i want to upload the images 
in facebook account."

Thanks in advance!!

Original comment by jds.c...@gmail.com on 23 Feb 2012 at 11:28

GoogleCodeExporter commented 8 years ago
why is your session a string?

Original comment by davidtal...@gmail.com on 1 Mar 2012 at 11:06

GoogleCodeExporter commented 8 years ago
hi

Original comment by hari041...@gmail.com on 15 May 2015 at 6:08