| Net-Social documentation | Contained in the Net-Social distribution. |
Net::Social::Service - the base package for all the Net::Social plugins
my $service = Net::Social->service('LiveJournal');
or
my $service = Net::Social::Service::LiveJournal->new;
Get the params needed
my %params = Net::Social::Service::LiveJournal->params;
or my %params = $service->params;
for my $what (qw(read write)) {
print "Can $what\n" if $params{$what};
}
# list what keys are needed to login
foreach my $key (keys %$params{read}) {
print "$key: ".$params{read}->{$key}."\n";
}
then
$service->login(%params);
foreach my $friend ($service->friends) {
print "$friend->{name} $friend->{type}\n";
}
$service->add_friend("frank");
$service->remove_friend("frank");
Create a new Service
What fields are needed to log in to this service.
This will return a hash ref, the keys of which will
be either read or write or one of each. If you log in
using the write params you will also be able to read.
Each of those will, in turn, be a hash ref the keys of which described what is needed. In turn their values will be another hash ref which can contain the fields
Always present. A description of the field.
Defaults to 0. Dictates whether this field is required or optional.
Defaults to 0. Whether or not this field is sensitive or not.
By sensitive we mean that it compromises the user's account. Examples of this might be, say, a password as opposed to a authorisation token.
This is a bit of a judgment call, to be honest.
Login in to this site.
All your friends on the site.
The friends will be return as a list of hash refs.
The hash refs will contain various fields depending
on the service returning the data such as name (the
person's full name), uid (the uid on the service),
username (a username on the service, may be the same
as uid). However each one will definitely contain type
which will be one of 4 values, defined as constants in
Net::Social.
There's no defined relationship between the two of you.
You've friended them but they haven't friended you.
They've friended you but you haven't friended them.
You've both friended each other. MUTUAL is defined as
MUTUAL = FRIENDED | FRIENDED_BY
In the future I may make all services return a key field or
similar which will be the field needed for adding or deleting.
Add a friend.
Remove a friend.
| Net-Social documentation | Contained in the Net-Social distribution. |
package Net::Social::Service; use strict;
sub new { my $class = shift; return bless { _logged_in => 0 }, $class; }
sub params { my $class = shift; return (); }
sub login { my $self = shift; my %params = @_; my %keys = $self->params; foreach my $p (keys %keys) { return undef if $keys{$p}->{required} && !exists $params{$p}; } $self->{_logged_in} = 1; $self->{_details} = \%params; return 1; }
sub friends { my $self = shift; return (); }
sub add_friend { }
sub remove_friend { } 1;