[twitter-dev] Re: Perl script for retrieving twits

2009-12-02 Thread Oreste
Thanks to Dave and natefanaro,

the Perl doc is quite clear, but I could not find a suitable property
or method that retrieves just my twits, the ones I generate from my
account.

thanks to Dave's suggestion I found the answer, which is the
following:

use Net::Twitter;
use Data::Dumper;
my $nt = Net::Twitter-new(
traits   = [qw/API::REST/],
username = 'user',
password = 'pass'
);
my $timeline = $nt-user_timeline;
for my $tweet (@$timeline) {
  print $tweet-{created_at} . ': ' . $tweet-{text};
}

working perfectly.

Thanks again


 Your $nt is just the interface to the API.  If you want to, say, get the
 latest status updates to your/your friends' accounts, you need to use
 that interface to retrieve them:

 my $timeline = $nt-friends_timeline;
 for my $tweet (@$timeline) {
   print $tweet-{created_at} . ': ' . $tweet-{text};

 }

 (Code is untested, but should work.  Note that the maintainer of
 Net::Twitter was talking a couple months ago about wrapping the
 retrieved messages up into objects, so $tweet may no longer be a bare
 hashref; I just haven't needed to update my direct Twitter-interfacing
 functions since then so I haven't stayed on top of it.  Check the
 Net::Twitter documentation for full details.)

 --
 Dave Sherohman


[twitter-dev] Re: Perl script for retrieving twits

2009-12-01 Thread natefanaro
You just built an object. If you want to read tweets you have to use a
function that retrieves them.

For example, if you want to search for tweets
my $r = $nt-search(hello world);
print Dumper $r;

It may help if you read the documentation for that module
http://search.cpan.org/dist/Net-Twitter/lib/Net/Twitter.pod

On Dec 1, 9:20 am, Oreste ore...@parlatano.org wrote:
 I'm usingNet::Twittermodule which is working nicely. I'm getting
 back a lot of variables, I need to grab just those variables giving me
 the message and date. Could you help me to find them out?

 This is the script I'm using:

 useNet::Twitter;
 use Data::Dumper;
 my $nt =Net::Twitter-new(
 traits   = [qw/API::REST/],
 username = 'user',
 password = 'pass'
 );
 print Dumper $nt;

 Here are the results:

 $VAR1 = bless( {
                  'ua' = bless( {
                                   'max_redirect' = 7,
                                   'protocols_forbidden' = undef,
                                   'no_proxy' = [],
                                   'protocols_allowed' = undef,
                                   'use_eval' = 1,
                                   'requests_redirectable' = [
                                                                'GET',
                                                                'HEAD'
                                                              ],
                                   'from' = undef,
                                   'timeout' = 180,
                                   'agent' = 'Net::Twitter/3.07001
 (Perl)',
                                   'def_headers' = bless( {
                                                             'x-twitter-
 client' = 'PerlNet::Twitter',
                                                             'x-twitter-
 client-version' = '3.07001',
                                                             'x-twitter-
 client-url' = 'http://search.cpan.org/dist/Net-Twitter/'
                                                           },
 'HTTP::Headers' ),
                                   'parse_head' = 1,
                                   'proxy' = {},
                                   'basic_authentication' = {

 'twitter.com:80' = {

 'Twitter API' = [

 'user',

 'pass'
                                                                               
                        ]
                                                                               
     }
                                                             },
                                   'max_size' = undef
                                 }, 'LWP::UserAgent' ),
                  'source' = 'twitterpm',
                  'decode_html_entities' = '0',
                  'netrc' = '0',
                  'clientname' = 'PerlNet::Twitter',
                  'useragent' = 'Net::Twitter/3.07001 (Perl)',
                  'apihost' = 'twitter.com:80',
                  'apirealm' = 'Twitter API',
                  'clientver' = '3.07001',
                  'password' = 'pass',
                  '_json_handler' = bless( [
                                              bless( do{\(my $o = '')},
 'JSON::XS' ),
                                              'encode',
                                              'decode',
                                              1
                                            ], 'JSON::Any' ),
                  'useragent_class' = 'LWP::UserAgent',
                  'clienturl' = 'http://search.cpan.org/dist/Net-Twitter/',
                  'ssl' = '0',
                  'useragent_args' = {},
                  'username' = 'user',
                  'apiurl' = 'http://twitter.com'
                }, 'Class::MOP::Class::__ANON__::SERIAL::2' );