How to get user information in twitter API using asp.net

I am currently working on a project using the twitter API.

I have a code like this:

using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Newtonsoft.Json.Linq; // Added for JSON Library ( Doc) using System.Xml; using oAuthExample; public partial class twitterInfo : System.Web.UI.Page { string url = ""; string xml = ""; public string name = ""; public string username = ""; public string profileImage = ""; public string followersCount = ""; public string noOfTweets = ""; public string recentTweet = ""; //Source http://www.aspdotnet-suresh.com/2012/05/add-twitter-login-authentication-to.html protected void Page_Load(object sender, EventArgs e) { GetUserDetailsFromTwitter(); } private void GetUserDetailsFromTwitter() { if (Request["oauth_token"] != null & Request["oauth_verifier"] != null) { imgTwitter.Visible = false; tbleTwitInfo.Visible = true; var oAuth = new oAuthTwitter(); //Get the access token and secret. oAuth.AccessTokenGet(Request["oauth_token"], Request["oauth_verifier"]); if (oAuth.TokenSecret.Length > 0) { url = "https://api.twitter.com/1.1/account/verify_credentials.json"; xml = oAuth.oAuthWebRequest(oAuthTwitter.Method.GET, url, String.Empty); JObject o = JObject.Parse(xml); name = Convert.ToString(o["name"]); username = Convert.ToString(o["screen_name"]); profileImage = Convert.ToString(o["profile_image_url"]); followersCount = Convert.ToString(o["followers_count"]); noOfTweets = Convert.ToString(o["statuses_count"]); noOfTweets = Convert.ToString(o["birthday"]); } } } protected void imgTwitter_Click(object sender, ImageClickEventArgs e) { var oAuth = new oAuthTwitter(); if (Request["oauth_token"] == null) { //Redirect the user to Twitter for authorization. //Using oauth_callback for local testing. // R_ use the dynamic url director // Call back URL to direct the user to the page oAuth.CallBackUrl = "http://localhost:518/Account/TwitterInfo.aspx"; Response.Redirect(oAuth.AuthorizationLinkGet()); } else { GetUserDetailsFromTwitter(); } } } 

This code is part of the Twitter API return project (name, twitterusername, profileimage, followers, and number of tweets). I know that the Twitter API does not receive users email address. but I want to get the user profile ID and the link to the user profile ... Can someone tell me what I need to change from the code above to get these two data?

Here is the link for all source code.

+4
source share
1 answer

The code you use for account / verify_credentials looks fine, and if that works, you can use the same code, but change the URL. The / verify _credentials account will work for an authenticated user, but you will need to use users / show to specify any user. There account / settings endpoint, but again, that only for the authenticated user.

Only an individual user can see their own settings page. You can send the user https://twitter.com/settings/account , which is their own profile page, but they must be registered to view it. I don’t know if this will meet your requirements, but one of the things you can do is define a separate public Twitter page, for example:

 string publicTwitterPage = "https://twitter.com/" + username; 
+3
source

All Articles