Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Taking a quick look at the verify_credentials API as mentioned by peSHIr, I wrote a little routine which seems to do the trick. It's late, but I was able to test it a couple of times and seems to work.</p> <p>In my function, I am just returning true if I I get an HttpResponseCode.OK, and false if I get anything else or an exception is thrown. If twitter does not like the uid/password an exception will be thrown with a 401 error (not authorized.)</p> <pre><code>public bool CheckTwitterCredentials(string UserName, string Password) { // Assume failure bool Result = false; // A try except block to handle any exceptions try { // Encode the user name with password string UserPass = Convert.ToBase64String( System.Text.Encoding.UTF8.GetBytes(UserName + ":" + Password)); // Create our HTTP web request object HttpWebRequest Request = (HttpWebRequest)WebRequest.Create("http://twitter.com/account/verify_credentials.xml"); // Set up our request flags and submit type Request.Method = "GET"; Request.ContentType = "application/x-www-form-urlencoded"; // Add the authorization header with the encoded user name and password Request.Headers.Add("Authorization", "Basic " + UserPass); // Use an HttpWebResponse object to handle the response from Twitter HttpWebResponse WebResponse = (HttpWebResponse)Request.GetResponse(); // Success if we get an OK response Result = WebResponse.StatusCode == HttpStatusCode.OK; } catch (Exception Ex) { System.Diagnostics.Debug.WriteLine("Error: " + Ex.Message); } // Return success/failure return Result; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload