2012-05-28 52 views
2

我正在使用facebook-android-sdk進行單一登錄,但我無法獲取用戶的Facebook資料數據。這是我的代碼:獲取用戶資料facebook使用oficial facebook-android-sdk

try { 
      JSONObject me = new JSONObject(facebook.request("me")); 
      String id = me.getString("id"); 
      String name = me.getString("name"); 
      System.out.println("Id: " + id + " ---- " + name); 
     }catch(Exception ex) { 
      System.out.println(ex); 
     } 

如何獲取用戶數據配置文件? 謝謝!

+0

我相信這是一個有效的問題 – Yar

回答

3

只要您在登錄

AsyncFacebookRunner myAsyncRunner = new AsyncFacebookRunner(facebook); 
myAsyncRunner.request("me", new meRequestListener()); 

請求聽衆:

public class meRequestListener implements RequestListener() { 

    @Override 
    public void onComplete(String response, Object state) { 
     //response is your JSON response 
    } 

    //You also have to override all the other methods 
} 
+1

正常工作與您的解決方案的感謝BananaNutTruffles –

+0

完美的代碼工作得很好,沒有錯誤或問題謝謝! –

相關問題