1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Twitter HTTP Post Error 403? Any Idea?

Discussion in 'General Programming Chat' started by Xaptor, Feb 7, 2009.

  1. Xaptor

    Xaptor Newbie

    Joined:
    Jan 4, 2009
    Messages:
    6
    Likes Received:
    0
    Hello guys,

    i have a little problem coding my twitter account creator. every time i want to post the http request i get an 403 error. Any ideas?
    The code is c# but i posted this thread here because it could be a generic http problem. For those c# people the post request:

    Code:
    request = (HttpWebRequest)WebRequest.Create("https://twitter.com/account/create");
    request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5 (.NET CLR 3.5.30729)";
    request.ContentType = "application/x-www-form-urlencoded";
    request.Referer = "https://twitter.com/signup";
    request.CookieContainer = new CookieContainer();
    request.CookieContainer.Add(Cookies);
    request.Method = "POST";
    string formString = String.Format("authenticity_token={0}&follow=&user[name]={1}&user[screen_name]={2}&user[user_password]={3}&user[email]={4}&user[send_email_newsletter]=0&recaptcha_response_field={5}&recaptcha_challenge_field={6}&commit=Create my account", HttpUtility.UrlEncode(token), HttpUtility.UrlEncode(fullname), HttpUtility.UrlEncode(username), HttpUtility.UrlEncode(password), HttpUtility.UrlEncode(email), HttpUtility.UrlEncode(solvedcaptcha), HttpUtility.UrlEncode(challenge));
    
    byte[] postData = Encoding.ASCII.GetBytes(formString); 
    Stream os = null;
    try
      {
           request.ContentLength = postData.Length; 
           os = request.GetRequestStream();
           os.Write (postData, 0, postData.Length);         //Send it
       }
    catch (WebException ex)
    {
            MessageBox.Show ( ex.Message, "HttpPost: Request error", 
               MessageBoxButtons.OK, MessageBoxIcon.Error );
    }
    finally
    {
             if (os != null)
             {
                  os.Close();
              }
    }

    best regards
    Xaptor