On Sun, Mar 22, 2009 at 8:04 PM, J.D. <[email protected]> wrote:

>
> I must be doing something wrong. If I call rate_limit_status with
> CURL, I can see 2 different counts, depending on if I pass my
> credentials or not. If I do the same thing from a .NET application, I
> always get the non-authenticated (IP address limit) results.
>
> I know setting the WebClient credentials this way works, as I call
> other twitter API's after authenticating, plus I can call
> verify_credentials this way and it works.
>
> Can anyone see what I'm missing or screwing up?
>
>      public void TestLimitInfo()
>      {
>         WebClient wc = new WebClient();
>         wc.Credentials = new NetworkCredential( "myuser", "mypass" );
>
>         string data = wc.DownloadString( "http://twitter.com/account/
> rate_limit_status.json" );
>         MessageBox.Show( data );
>
>      }  // GetLimitInfo
>
> TIA,
> J.D.
>
If WebClient works the way HttpWebRequest does, it sends 2 requests. The
first is an unauthenticated request to get the auth header, the second is
the authenticated response (authenticated to the highest mutually agreeable
auth scheme). The problem for Twitter is that the first response will count
against unauthenticated requests, and the second counts against the
authenticated requests.

I made it work for Witty by manually attaching the BasicAuth header to the
webrequest before we sent it. I don't know if WebClient allows that. You may
want to consider going with HttpWebRequest and HttpWebResponse.

JD

Reply via email to