Twitter Search API The remote server returned an error: (403) Forbidden



when I’m trying to get these information with ASP.NET (C#), I get an error:

The remote server returned an error (403) Forbidden.

Here is the code I’m using to make an Get Request.

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)
                    //We now have the credentials, so make a call to the Twitter API.
                    url = "";
                    xml = oAuth.oAuthWebRequest(oAuthTwitter.Method.POST, url, String.Empty);
                    XmlDocument xmldoc = new XmlDocument();
                    XmlNodeList xmlList = xmldoc.SelectNodes("/user");
                    foreach (XmlNode node in xmlList)
                        name = node["name"].InnerText;
                        username = node["screen_name"].InnerText;
                        profileImage = node["profile_image_url"].InnerText;
                        followersCount = node["followers_count"].InnerText;
                        noOfTweets = node["statuses_count"].InnerText;
                        recentTweet = node["status"]["text"].InnerText;


url = "";

I’m not sure where you got your code sample, but this is very out-of-date. The Twitter API v1 was closed down in 2012 and the API endpoints have not supported XML for around the same period of time.

You should look for a more up-to-date example using JSON.

The correct endpoint would be /1.1/account/verify_credentials.json


Thank you…:slight_smile: