bobolounna / restfb

Automatically exported from code.google.com/p/restfb
0 stars 0 forks source link

J2ME implementation of restfb URGENT #74

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
1.how to connect with facebook using j2me and restfb?
2.how can I obtain my auth_token via j2me app without opening mobile browser?

need code example !!! Urgent !!!

implementing the following through j2me

    * Create a Facebook Application
    * Request https://graph.facebook.com/oauth/authorize?client_id=MY_API_KEY& redirect_uri=http://www.facebook.com/connect/login_success.html& scope=publish_stream,offline_access,create_event
    * Facebook will redirect you to http://www.facebook.com/connect/login_success.html? code=MY_VERIFICATION_CODE
    * Request https://graph.facebook.com/oauth/access_token?client_id=MY_API_KEY& redirect_uri=http://www.facebook.com/connect/login_success.html& client_secret=MY_API_SECRET&code=MY_VERIFICATION_CODE
    * Facebook will respond with access_token=MY_ACCESS_TOKEN

My Code so far:

HttpConnection connection = null;
        DataInputStream in = null;
        String url = "https://graph.facebook.com/oauth/authorize?client_id=APP_KEY&%20redirect_uri=http://www.facebook.com/connect/login_success.html&%20scope=publish_stream";

        OutputStream out = null;
        //try {
            System.out.println("@@@@@1");
            connection = (HttpConnection) Connector.open(url);
            System.out.println("@@@@@2");
            connection.setRequestMethod(HttpConnection.POST);
            //connection.setRequestProperty("IF-Modified-Since", "2 Oct 2002 15:10:15 GMT");
            connection.setRequestProperty("User-Agent", "Profile/MIDP-2.0 Configuration/CLDC-1.0");
            connection.setRequestProperty("Content-Language", "en-US");
            connection.setRequestProperty("Content-Length", "" + (UserName.length() + PassWord.length()));
            connection.setRequestProperty("UserName", UserName);
            connection.setRequestProperty("PassWord", PassWord);
            System.out.println("@@@@@3");
            out = connection.openDataOutputStream();
            System.out.println("@@@@@4");
            //out.write();
            out.flush();
            System.out.println("@@@@@5");

            in = connection.openDataInputStream();//receiving error here

            System.out.println("@@@@@6");
            int ch;
            while ((ch = in.read()) != -1) {
                System.out.println("@@@@@7");
                b.append((char) ch);
                //System.out.println((char)ch);
            }

Original issue reported on code.google.com by abhi007t...@gmail.com on 10 Sep 2010 at 3:06

GoogleCodeExporter commented 8 years ago
1. J2ME is not a supported platform for RestFB.
2. The OAuth code example you are requesting is not part of RestFB - you must 
open a mobile browser or write your own scraping code (not recommended).  Read 
the Facebook documentation.

Closing as invalid.

Original comment by mark.a.a...@gmail.com on 10 Sep 2010 at 3:45