Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Twitter API choices

by JediMasterT (Sexton)
on Nov 28, 2011 at 16:12 UTC ( #940413=perlquestion: print w/replies, xml ) Need Help??

JediMasterT has asked for the wisdom of the Perl Monks concerning the following question:

As a real-world application, and to learn a bit more about HTTP and parsing, I am using the Twitter API to search for the 20 latest mentions of someones name. The API that I would be using, "REST API", can send this information in four formats: XML, JSON, RSS, and atom. Because there are so many options, so many libraries for each option, and because it's an interesting discussion topic, I thought I'd ask the monks of Perl wisdom: Which format/library would be best for this situation?

PS, the documentation is here

Replies are listed 'Best First'.
Re: Twitter API choices (JSON)
by tye (Sage) on Nov 28, 2011 at 17:40 UTC

    My preferred format is JSON. It is tons simpler than any of the other listed formats (and is tons simpler than most formats; it only gets a little complicated if you have to deal with non-ASCII characters). JSON::XS is widely used and rarely complained about (I'll complain about it later and then I'll replace it with a small regex, which I can easily do because JSON is so simple).

    - tye        

      +1 for JSON (and JSON::XS). RSS and Atom are both XML-based, so your choices really boil down to JSON or XML, if you're wanting to do the parsing yourself.

      I'll add a +1 for JSON, too... of course, that's just because that's what I'm learning right now :-)


Re: Twitter API choices
by mrguy123 (Hermit) on Nov 29, 2011 at 08:15 UTC

    The nice thing about XML is that you have so many great XML parsers, such as XML::Simple, XML::Twig, and many more, so this might also be a good opportunity to learn to use this modules.

    Good Luck,
Re: Twitter API choices
by wol (Hermit) on Nov 29, 2011 at 11:27 UTC
    Well, if I needed something "just to get the job done", then I'd probably pick JSON.

    However, if this is a learning oportunity, then I suggest that you try both JSON and XML. Hope you have time for that. ;)

    use JAPH;
    print JAPH::asString();
Re: Twitter API choices
by jdrago999 (Pilgrim) on Nov 29, 2011 at 21:43 UTC

    The venerable Net::Twitter is really, really nice. Is there something you need that it doesn't already provide?

      I suspected there would be a Twitter module...
      To answer your question, no, not really. It's just a fun, real world application that uses live, real world data.

Re: Twitter API choices
by JavaFan (Canon) on Nov 28, 2011 at 16:33 UTC
    Why don't you pick the format *you* are most comfortable with? That sure beats whatever *my* preference will be.

      I can understand where you're coming from, and that's usually what I would tell other people, but I asked this questions for three reasons: First, I am at the same level of comfort with all of them, which is to say barely at all; Second, I've never dealt with formal parsing in Perl, so this was kind of asking where to start from; and last, I think it could be an interesting discussion.

      Maybe I should put the discussion part somewhere else, but I'm fairly new to PerlMonks too, so have no idea where, or how.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://940413]
Front-paged by Arunbear
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2021-04-16 02:04 GMT
Find Nodes?
    Voting Booth?

    No recent polls found