Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7931549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:45:10+00:00 2026-06-03T20:45:10+00:00

I am developing an application using twitter api and that involves writing a method

  • 0

I am developing an application using twitter api and that involves writing a method to check if a user exists. Here is my code:

  public static bool checkUserExists(string user)
    {
        //string URL = "https://twitter.com/" + user.Trim();
        //string URL = "http://api.twitter.com/1/users/show.xml?screen_name=" + user.Trim();
        //string URL = "http://google.com/#hl=en&sclient=psy-ab&q=" + user.Trim();
        string URL = "http://api.twitter.com/1/users/show.json?screen_name=" + user.Trim();
        HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(URL);
        try
        {
            var webResponse = (HttpWebResponse)webRequest.GetResponse();
            return true;
        }
        //this part onwards does not matter
        catch (WebException ex)
        {
            if (ex.Status == WebExceptionStatus.ProtocolError && ex.Response != null)
            {
                var resp = (HttpWebResponse)ex.Response;
                if (resp.StatusCode == HttpStatusCode.NotFound)
                {
                    return false;
                }
                else
                {
                    throw new Exception("Unknown level 1 Exception", ex);
                }
            }
            else
            {
                throw new Exception("Unknown level 2 Exception", ex);
            }
        }
    }

The problem is, calling the method does not work(it doesn’t get a response) more than 2 or 3 times, using any of the urls that have been commented, including the google search query(I thought it might be due to twitter API limit). On debug, it shows that it’s stuck at:

var webResponse = (HttpWebResponse)webRequest.GetResponse();

Here’s how I am calling it:

Console.WriteLine(TwitterFollowers.checkUserExists("handle1"));
Console.WriteLine(TwitterFollowers.checkUserExists("handle2"));
Console.WriteLine(TwitterFollowers.checkUserExists("handle3"));
Console.WriteLine(TwitterFollowers.checkUserExists("handle4"));
Console.WriteLine(TwitterFollowers.checkUserExists("handle5"));
Console.WriteLine(TwitterFollowers.checkUserExists("handle6"));

At most I get 2-3 lines of output. Could someone please point out what’s wrong?

Update 1:
I sent 1 request every 15 seconds (well within limit) and it still causes an error. on the other hand, sending a request, closing the app and running it again works very well (on average accounts to 1 request every 5 seconds). The rate limit is 150 calls per hour Twitter FAQ.

Also, I did wait for a while, and got this exception at level 2:
http://pastie.org/3897499

Update 2:
Might sound surprising but if I run fiddler, it works perfectly. Regardless of whether I target this process or not!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T20:45:12+00:00Added an answer on June 3, 2026 at 8:45 pm
    1. Note that you’re dealing with unmanaged resources underneath your HttpWebResponse. So calling Dispose() in a timely fashion or
      wrapping the object in a using statement is not only wise, but important to avoid blocking.
    2. Also, var is great for dealing with anonymous types, Linq query
      results, and such but it should not become a crutch. Why use var
      when you’re well aware of the type? (i.e. you’re already performing
      a cast to HttpWebResponse.)
    3. Finally, services like this often limit the rate of connections per second and/or the number of simultaneous connections allowed to prevent abuse. By not disposing of your HttpWebResponse objects, you may be violating the permitted number of simultaneous connections. By querying too often you’d break the rate limit.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a application that uses the twitter API. I'm currently using rspec with
Any good source/website/inputs/sample to kickstart developing a twitter application using twitter API? Edit :
I am using spring 3.0.2 for developing a simple web based application like twitter.
I'm developing application using backbone.js & jquery. I have following code in model: runReport:
I'm developing an application using MS Visual C# 2008 Express that uses the ClickOnce
I'm developing Twitter application with xAuth support using twitter4j jar file. I want to
I'm developing a little Twitter application on iOS 5. I'm using Twitter and Accounts
I'm developing an iOS application , that will take a twits from twitter, I'm
i am developing an application using c#.net in which i need that if a
We are developing an asp.net 2.0 web application in that user can sign-up or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.