2013-07-18 27 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)