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

Problem with Twitter profile uploading

Discussion in 'C, C++, C#' started by forwardedlandlines, May 30, 2012.

  1. forwardedlandlines

    forwardedlandlines Jr. VIP Jr. VIP

    Joined:
    Feb 10, 2012
    Messages:
    540
    Likes Received:
    372
    I've been trying for ages to create a Twitter account with httpwebrequest and upload a profile, but I keep hitting a 500 - Internal Server Error, in that very last phase. I pass the oauth stuff by signing up on their mobile site, and keep good check on cookies. Note that this should work perfectly as I have tried it exactly this way in Firefox with Javascript disabled. I made my request formats (GET and multipart formdata POST) IDENTICAL to what firefox shows me in their webconsole.. I don't get it ... anyone ?!
     
    Last edited: May 30, 2012
  2. Chris22

    Chris22 Regular Member

    Joined:
    Sep 29, 2010
    Messages:
    400
    Likes Received:
    1,059
    Are you using SSL on the right requests?

    A twitter bot I made once had similar errors, and I fixed it by double checking the protocol.
     
  3. theMagicNumber

    theMagicNumber Regular Member

    Joined:
    May 13, 2010
    Messages:
    345
    Likes Received:
    195
    Do you escape your post data correctly?
    Using Uri.EscapeDataString or HttpUtility.UrlEncode
    I am using a simple helper method to construct the post data.

    Code:
    public static string FormattPostData(List<KeyValuePair<string, string>> data)
            {
                StringBuilder result = new StringBuilder();
                foreach (KeyValuePair<string, string> kv in data)
                {
                    result.Append("&");
                    result.Append(kv.Key);
                    result.Append("=");
                    result.Append(Uri.EscapeDataString(kv.Value));
                }
                return result.Remove(0, 1).ToString();
            }
    
    Anyway i will do more research soon, as i am interested in twitter account creation bot too, and will contact you back.
     
  4. forwardedlandlines

    forwardedlandlines Jr. VIP Jr. VIP

    Joined:
    Feb 10, 2012
    Messages:
    540
    Likes Received:
    372
    Well it's about the final post that updates the profile. It's a different kind of post. Namely a multipart formdata post with boundaries etc. I believe that my post is flawless, yet it gets blocked, while firefox passes... Heck it may even have to do with that I'm not loading images, or requesting it too fast..
     
  5. forwardedlandlines

    forwardedlandlines Jr. VIP Jr. VIP

    Joined:
    Feb 10, 2012
    Messages:
    540
    Likes Received:
    372
    After MANY hours I FINALLY got it right. Now I finally have a full automated Twitter maker :)
     
  6. Chris22

    Chris22 Regular Member

    Joined:
    Sep 29, 2010
    Messages:
    400
    Likes Received:
    1,059
    Nice work, what was the problem in the end?
     
  7. forwardedlandlines

    forwardedlandlines Jr. VIP Jr. VIP

    Joined:
    Feb 10, 2012
    Messages:
    540
    Likes Received:
    372
    Just the whole multipart form upload needed to be perfect to the bit, AND they changed their upload protocol right after I analyzed it. So I kept trying to upload with an old protocol. Talk about coincidence...