2012-05-26 55 views
0
*I am easily getting a token from my app but when I am trying to get the ID or user ID, I can't. 

    Facebook authenticatedFacebook = new Facebook(APP_ID); 

After this I call the Facebook API and get a token. 

    String token=data.getStringExtra("access_token"); 
    jsonobj=new JSONObject(authenticatedFacebook.request("https://graph.facebook.com/me?access_token="+token)); 

or 

    jsonobj=new JSONObject(authenticatedFacebook.request("/me?access_token="+token)); 

or 

    jsonobj=new JSONObject(authenticatedFacebook.request("me?access_token="+token)); 
    // jsonresponseArray=jsonobj.getJSONArray("id"); 
    System.out.println("the id has"+jsonobj.has("id")); 
String usrid=jsonobj.getString("id"); 
so it give me error that it doesn't have any id field. 
So please, can you give me a solution? And thanks in advance.* 

回答

0

喜按以下行,你可以這樣做:

/我會返回一個JSON對象有id字段(及​​其他)。您可以解析此JSON對象是這樣的:

JSONObject json = Util.parseJson(facebook.request("me", params)); 
String userId = json.getString("id"); 
+0

哎拉傑什我已經嘗試過這一點,這是行不通的 – itechDroid

+0

哎,我只是忘了在包中添加參數,以便感謝記得我 – itechDroid

+0

高興聽到它 – itsrajesh4uguys

相關問題