Kerala Microsoft Users Group

Problem using Twitter API from C#

Latest post 04-20-2009 8:43 AM by Shoban Kumar. 4 replies.
  • 04-14-2009 3:37 AM

    Problem using Twitter API from C#

    Hi All

    I am trying to implement a simple Twitter client. I am able to get the status but when I try to Update it I am getting 403 Error from Twitter, here is the code I am using

    string uri = "http://twitter.com/statuses/update.xml";
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
    request.Method = "POST";
               
    request.Credentials = new NetworkCredential("username", "password");
    request.ContentType = "application/x-www-from-urlencoded";       
    string postData = "status=Sample Status";
    byte[] encodedData = new ASCIIEncoding().GetBytes(postData);
    request.ContentLength = encodedData.Length;
    Stream requestStream = request.GetRequestStream();
    requestStream.Write(encodedData, 0, encodedData.Length);       

    //I am getting error from the next statement

    //Error : The remote server returned an error: (403) Forbidden.
    using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
    {
    using (StreamReader reader = new StreamReader(response.GetResponseStream()))
    {
    /*
    More code
    */

    Please help

    Thanks

    Anuraj P
    http://www.dotnetthoughts.net

    THIS POSTING IS PROVIDED "AS IS" WITH NO WARRANTIES, AND CONFERS NO RIGHTS.
    BEWARE OF BUGS IN THE ABOVE CODE; I HAVE ONLY PROVED IT CORRECT, NOT TRIED IT.

    Filed under: , ,
    • Post Points: 25
  • 04-14-2009 9:52 AM In reply to

    Re: Problem using Twitter API from C#

    Have you proted your updates in Twitter? Here is a c# open source twitter api if you are interested. http://devblog.yedda.com/index.php/2007/05/16/twitter-c-library/

    • Post Points: 25
  • 04-15-2009 5:24 AM In reply to

    Re: Problem using Twitter API from C#

    Thanks Shoban, let me check that one.

    Thanks

    Anuraj P
    http://www.dotnetthoughts.net

    THIS POSTING IS PROVIDED "AS IS" WITH NO WARRANTIES, AND CONFERS NO RIGHTS.
    BEWARE OF BUGS IN THE ABOVE CODE; I HAVE ONLY PROVED IT CORRECT, NOT TRIED IT.

    • Post Points: 5
  • 04-20-2009 7:42 AM In reply to

    Re: Problem using Twitter API from C#

    It is resolved. Smile

    But the client name not coming, it is coming as WEB

    Thanks

    Anuraj P
    http://www.dotnetthoughts.net

    THIS POSTING IS PROVIDED "AS IS" WITH NO WARRANTIES, AND CONFERS NO RIGHTS.
    BEWARE OF BUGS IN THE ABOVE CODE; I HAVE ONLY PROVED IT CORRECT, NOT TRIED IT.

    • Post Points: 25
  • 04-20-2009 8:43 AM In reply to

    Re: Problem using Twitter API from C#

    Great! Client name wont be displayed unless you register the client name with Twitter. Its easy too, You just have to send an email to Twitter with your client details (name, homepage etc).

    Twitter is blocked in office. I will post more details about it soon. You can get the details from Twitter API wiki pages. The parameter is "source"

     

    • Post Points: 5
Page 1 of 1 (5 items) | RSS