bobolounna / restfb

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

authentication issue #167

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi I am facing the problem regarding the authentication issue with java desktop 
based application, code is given below:

package test;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;

import com.google.code.facebookapi.FacebookJsonRestClient;

public class WallPostClass {
    public static String API_KEY = "............";
    public static String SECRET = ".................";
    static FacebookJsonRestClient client =new FacebookJsonRestClient(API_KEY, SECRET) ;

    public void meth()throws Exception{
        String feedUrl = "https://graph.facebook.com/<user_id>/feed";
        String data = URLEncoder.encode("access_token", "UTF-8") + "=" + URLEncoder.encode(client.auth_createToken(), "UTF-8");
        data += "&" + URLEncoder.encode("message", "UTF-8") + "=" + URLEncoder.encode("Hey God! Pl help me", "UTF-8");
        // Send data
        URL url = new URL(feedUrl) ;
        URLConnection conn = url.openConnection() ;
        conn.setDoOutput(true) ; 

        OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
        wr.write(data);
        wr.flush();
        // Get the response
        BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        String line;
        while ((line = rd.readLine()) != null) {
            // Process line...
            System.out.println(line);
        }
        wr.close();
        rd.close();
    }
    public static void main(String[] args) {

        try {
            new WallPostDemo3().meth();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

}

I am stuffing with the user_id that what should be the user id whether username 
or other..

Pl help me out ASAP

Regards
Ishant Agarwal

Original issue reported on code.google.com by niitish...@gmail.com on 9 Dec 2011 at 2:44

GoogleCodeExporter commented 9 years ago
This is not a RestFB code snippet, it's something from another FB client.  
Marking invalid

Original comment by m...@xmog.com on 13 Dec 2011 at 7:06

GoogleCodeExporter commented 9 years ago
can you tell me that how to do it with RestFB API because I dont have found a 
relevant material over there...

Original comment by niitish...@gmail.com on 14 Dec 2011 at 11:59