NAME
Net::Gnip - interact with Gnip
SYNOPSIS
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);
METHODS
new <username> <password>
Create a new Gnip object
fetch <publisher> [datetime])
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.
publish <activity stream>
Publish an activity stream.
publish <publisher name> <activity[s]>
filters <publisher name>
Get a list of filters for this publisher.
Returns a list of Net::Gnip::Filter
objects.
create_filter <publisher name> <filter>
Creates a new filter.
get_filter <publisher name> <filter>
Fetches an existing filter.
filter
can either be a filter object or a name.
Returns a Net::Gnip::Filter
object.
update_filter <publisher name> <filter>
Updates an existing filter.
filter
can either be a filter object or a name.
Returns 1 on success and 0 on failure.
delete_filter <publisher name> <filter>
Deletes an existing filter.
filter
can either be a filter object or a name.
add_filter_rule <publisher> <filter> <type> <value>
Incrementally add a filter rule.
delete_filter_rule <publisher> <filter> <type> <value>
Incrementally delete a filter rule.
publishers
Gets a list of publishers on the system
create_publisher <publisher[s]>
Takes one or more Net::Gnip::Publisher
objects and creates them.
Returns 1 on success and undef on failure (and sets $@
)
get <url>
Does an HTTP GET request of the passed in url
, and returns the result from the server.
Returns undef on failure (and sets $@
)
post <url> <data object>
Does a HTTP POST request of the passed in url and data object, and returns the result from the server.
Returns undef on failure (and sets $@
)
put <url> <data>
Does an HTTP PUT request of the passed in url and data object, and returns the result from the server.
Returns undef on failure (and sets $@
)
delete <url>
Does a HTTP Delete request of the passed in url and returns the result from the server.
Returns undef on failure (and sets $@
)
round_time_to_nearest_bucket <datetime>
Rounds the time passed in down to the previous 1 minute mark.
Returns a new DateTime
object.
sync_with_gnip_clock <datetime>
This method gets the current time from the Gnip server.
Returns a new DateTime
object.
time_to_string <datetime>
Converts the time passed in to a string of the form YYYYMMDDHHMM.
AUTHOR
Simon Wistow <simon@thegestalt.org>
Based on code by ajackson from http://github.com/gnip/gnip-perl/tree/master
COPYRIGHT
Copyright 2008, Simon Wistow
Release under the same terms as Perl itself.