如何让perl与gmail聊天一起工作?

时间:2014-02-14 15:02:47

标签: perl xmpp google-talk

我尝试了thisthis。但它只是不起作用。 AuthSend返回空数组。可能我应该为你提供一些代码来讨论:

#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;

use Net::XMPP;
use Data::Dumper;

my $username = 'USERNAME';
my $password = 'PASSWORD';
my $connection = new Net::XMPP::Client;
my $r = $connection->Connect(
    hostname => 'talk.google.com',
    port => 5222,
    componentname => 'gmail.com',
    connectiontype => 'tcpip',
    tls => 1
);
say Dumper $r;
my @r = $connection->AuthSend(
    username => $username,
    password => $password,
    resource => 'test'
);
say Dumper \@r;

1 个答案:

答案 0 :(得分:-1)

您可以尝试Net::XMPP::Client::GTalk

#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;

use Data::Dumper;
use Net::XMPP::Client::GTalk;

my $username = 'USERNAME';
my $password = 'PASSWORD';

# does all the connection-handling and authentication at once
my $client = Net::XMPP::Client::GTalk->new(
    USERNAME => $username,
    PASSWORD => $password,
);

say Dumper($client);