Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^3: How do I use curl with perl and Twitter

by Corion (Patriarch)
on Jul 21, 2009 at 06:31 UTC ( [id://781863]=note: print w/replies, xml ) Need Help??


in reply to Re^2: How do I use curl with perl and Twitter
in thread How do I use curl with perl and Twitter

I'm not sure that what you wrote above would work, because the apihost parameter is, unsurprisingly, documented in the Net::Twitter as:

A string containing the Twitter API host. It defaults to "twitter.com:80". This option is available when the API::REST trait is included.

I'm not sure where you get the idea that you have to construct any URLs yourself - this is what the module should shield you from. But I'm sure that, instead of theoretical musings, it would be far more productive if you actually tried things out and came back only if you had further questions or error messages to report.

Replies are listed 'Best First'.
Re^4: How do I use curl with perl and Twitter
by northwestdev (Acolyte) on Jul 21, 2009 at 07:24 UTC
    Actually, you're shielded from the URL only if you use certain methods. show_user is not one of them: you need to specify a user, and a format in the URL. I should be setting apiurl instead of apihost. Confusion resulting from using apihost in PHP with curl. In any case, I figured out why I kept getting error 500. I took out all code, except for a statement to print out Hello World. When I commented out the use Net::Twitter, it printed out fine, and when I put it back in, I got error 500. This happened on a hosting account I have on goDaddy and another I have on a generic Apache Host. So, it seems as if Net::Twitter is not in general use as a Perl module.

      I don't see, neither from the documentation nor from the Net::Twitter code, where you would need to construct an URL, or a format yourself. The ->show_user method seems to take a user ID, it requests the JSON formatted user details and then turns them into a Perl data structure.

      If you don't have Net::Twitter installed on your host, you can easily install it, by following Yes, even you can use CPAN

        Net::Twitter is installed. I am no longer getting errors, but this piece of code is not producing any output (and the foreach loop is straight out of http://cpansearch.perl.org/src/CTHOM/Net-Twitter-2.06/README
        my $nt = Net::Twitter->new( traits => [qw/API::REST/], username => $usename, password => $pwd ); my $results = $nt->show_user($twitterID); foreach my $user (@{ $results }) { my $id = $user->{id}; my $name = $user->{name}; print STDOUT $id." ".$name."<br>"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://781863]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-03-29 05:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found