I’m confused

Head First Programming Chapter 3

Hey there,

The Twitter API function in Chapter 3 doesn't work. It returns this error message:
TypeError("POST data should be bytes"
TypeError: POST data should be bytes or an iterable of bytes. It cannot be str.

Someone mentioned on the web it has to do with twitter switching to OAuth and not supporting BasicAuth but whadda I know. I'm only up to Chapter 3...

Please help :)
1 person has
this problem
+1
Reply
  • Hi Dean,

    Thanks for writing, and I'm sorry you're experiencing a problem with that example in the book. Unfortunately, shortly after the book published, Twitter decided to change how programs interact with their web site and they effectively took something that was really easy and made it hard. This, of course, broke the book's code.

    The book's support web site (http://programming.itcarlow.ie) highlights this issue on its homepage. It also includes a link to the book's support forum (http://forums.oreilly.com/topic/20756..., where the issue is discussed in some detail. As you'll see when you read the forum entry, some people have managed to get this to work, while others continue to have difficulty.

    For what it is worth, the main learning point of this chapter in the book is *not* to be able to send messages to Twitter; it's to be able to send data to functions and have something happen. Having the data appear on Twitter was really just the icing on the cake. If you understand what's happening to your data when it enters the function, you should move on to the rest of the book's material and not spend too much time trying to get the Twitter bit to work.

    Regards,
    Brian Sawyer
    Senior Editor, O'Reilly Media
    @briansawyer
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated

  • I’m happy
    Hey Brian,

    Thanks for the details :)

    Cheers
    Dean
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated

  • This reply was removed on 2012-05-07.
    see the change log
  • This reply was removed on 2012-07-19.
    see the change log