2013-07-18 26 views
0

我正在爲其客戶端添加用戶和他們的Twitter用戶名的後端平臺上工作。前端是一個android/ios應用程序,應用程序的用戶可以在其中打開Twitter應用程序意圖。通過以JSON格式編碼的HTTP請求獲取Twitter用戶ID

爲Android似乎是,代碼如下:

int userId; 
try { 
     getPackageManager().getPackageInfo("com.twitter.android", 0); 
     intent = new Intent(Intent.ACTION_VIEW, Uri.parse("twitter://user?user_id="+userId)); 
     intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
    } catch (Exception e) { 
     intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://twitter.com/"+userId)); 
    } 
    this.startActivity(intent); 

如此看來,我需要使用,而不是用戶名的用戶ID。

因此,我想知道是否有任何方法可以使用twitter/GET來獲取用戶名的user_id,如果可能的話,使用JSON格式。

回答

0

實測溶液

Uri.parse("twitter://user?screen_name="+username)