Net::Gnip - interact with Gnip
use Net::Gnip; my $gnip = Net::Gnip->new($user, $pass, $publisher_name); # Get a list of publisher my @publisher = $gnip->publishers(); $gnip->create_publisher($name); # Create an activity and publish it my $activity = Net::Gnip::Activity->new('added_friend', 'me'); $gnip->publish($publisher_name, $activity); # or $gnip->publish($publisher_name, @activities); # or $gnip->publish($activity_stream); # Retrieve activities for a given publisher my $stream = $gnip->fetch(notification => $publisher_name); foreach my $activity ($stream->activities) { print "Type=".$activity->type."\n"; } # Retrieve activities for a given publisher 10 minutes ago my $stream = $gnip->fetch(notification => $publisher_name, time => 10*60); # Retrieve activities for a given publisher from a specific time my $stream = $gnip->fetch(notification => $publisher_name, time => $dt); # The same but get the full date my $stream = $gnip->fetch(activity => $publisher_name, time => $dt); # Create a filter and my @rules = ( { type => 'actor', value => 'joe' } ); my $filter = Net::Gnip::Filter->new('my_filter', 'true', [@rules]); my $result = $gnip->create_filter($publisher_name, $filter); # Get a list of filters foreach my $filters ($gnip->filters($publisher_name)) { print $filter->name."\n"; } # Get the activities from it my $stream = $gnip->fetch(activity => $publisher_name, filter => $filter_name); foreach my $activity ($stream->activities) { print "Type=".$activity->type."\n"; } # Update it $filter->full('false'); $gnip->update_filter($publisher_name, $filter); $gnip->add_filter_rule($filter, 'actor', 'simon'); $gnip->delete_filter_rule($filter, 'actor', 'simon') # Delete it $gnip->delete_filter($publisher_name, $filter);
Create a new Gnip object
Gets all of the data for a specific publisher, based on the datetime parameter.
If datetime is not passed in, the current time will be used.
Note that all times need to be as UTC DateTime objects.
Returns a Net::Gnip::ActivityStream object.
Net::Gnip::ActivityStream
Publish an activity stream.
Get a list of filters for this publisher.
Returns a list of Net::Gnip::Filter objects.
Net::Gnip::Filter
Creates a new filter.
Fetches an existing filter.
filter can either be a filter object or a name.
filter
Returns a Net::Gnip::Filter object.
Updates an existing filter.
Returns 1 on success and 0 on failure.
Deletes an existing filter.
Incrementally add a filter rule.
Incrementally delete a filter rule.
Gets a list of publishers on the system
Takes one or more Net::Gnip::Publisher objects and creates them.
Net::Gnip::Publisher
Returns 1 on success and undef on failure (and sets $@)
$@
Does an HTTP GET request of the passed in url, and returns the result from the server.
url
Returns undef on failure (and sets $@)
Does a HTTP POST request of the passed in url and data object, and returns the result from the server.
Does an HTTP PUT request of the passed in url and data object, and returns the result from the server.
Does a HTTP Delete request of the passed in url and returns the result from the server.
Rounds the time passed in down to the previous 1 minute mark.
Returns a new DateTime object.
DateTime
This method gets the current time from the Gnip server.
Converts the time passed in to a string of the form YYYYMMDDHHMM.
Simon Wistow <simon@thegestalt.org>
Based on code by ajackson from http://github.com/gnip/gnip-perl/tree/master
Copyright 2008, Simon Wistow
Release under the same terms as Perl itself.
To install Net::Gnip, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Gnip
CPAN shell
perl -MCPAN -e shell install Net::Gnip
For more information on module installation, please visit the detailed CPAN module installation guide.