| Badge-GoogleTalk documentation | view source | Contained in the Badge-GoogleTalk distribution. |
Badge::GoogleTalk - To get your status message/online status/chat link from google talk badge for website live chat.
version 0.3
use Badge::GoogleTalk; my $my_object = Badge::GoogleTalk->new( key => "your identification key", ); # Get Your Badge's online status my $online_status = $my_object->is_online(); my $ol_status = $online_status == 0 ? "Offline" : "Online"; # Get Your Badge's status message my $status = $my_object->get_status(); # Check Your Badge's away status my $away_status = $my_object->is_away(); my $aw_status = $away_status == 1 ? "Away" : "Online"; # Check Your Badge's Style my $style = $my_object->is_classic_style(); my $style_status = $style == 1 ? "Classic badge or one/two line style" : "Hyperlink and status icon style"; # Your Badge's in HTML format my $badge = $my_object->get_badge(); # Your chat link for your website my $chat_link = $my_object->get_chat_box_link(); To create a simple Badge::GoogleTalk you must pass the key; key is your identification from the google authentication. To create your chatback badge, visit http://www.google.com/talk/service/badge/New. If you're using a Google Apps account, you can create a chatback badge by visiting http://www.google.com/talk/service/a/DOMAIN/badge/New where DOMAIN is the name of your domain. Use the alphanumeric account hash to pass as key in constructor
A simple perl module for retrieving a user's Google Talk status Google does provide a badge, to post your status/images/links to your website to start a chat. Using this code, we can extract the status messages, online status, chat box link and return that information to our perl application to keep up the live chat.
This module depends on the output from a hosted web page by Google. If Google decides at any time to change this output, the module will likely fail. Please e-mail me if this is the case, so we can get it working again.
my $query_link = 'http://www.google.com/talk/service/badge/Show?tk=';
my $self = { %args };
_warn_user('Error',"User key is must to use this module :".
"For more info please see the module pod") if(!defined $self->{'key'});
$self->{'talk_url'} = $query_link.$self->{'key'};
bless $self, $class or die "Can't bless $class: $!";
return $self;
}
my $mech = WWW::Mechanize->new();
$mech->get($self->{'talk_url'});
my $page_contents = $mech->content();
my $content_type = $mech->ct();
my $response = $mech->status();
_warn_user('Error','Provided user key is in-valid !') if($response == '400');
$self->{'is_badge_html'} = $mech->is_html() ? 1 : 0 ;
_warn_user('Warning',"Your Badge's is Hyperlink and status icon style".
"sorry can't process for this style") if(!$self->{'is_badge_html'});
return $page_contents;
}
1; # Magic true value required at end of module __END__
Badge::GoogleTalk requires no configuration files or environment variables.
This module have the dependencies with the following modules WWW::Mechanize
No bugs have been reported. Please report any bugs or feature requests to C<bug-badge-googletalk@rt.cpan.org>, or through the web interface at L<http://rt.cpan.org>.
Rakesh Kumar Shardiwal <rakesh.shardiwal@gmail.com>
Copyright (c) 2009, Rakesh Kumar Shardiwal <rakesh.shardiwal@gmail.com>. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
| Badge-GoogleTalk documentation | view source | Contained in the Badge-GoogleTalk distribution. |