Thread undefined value as a HASH reference - problem (7 answers)
Opened by Mindfoo at 2009-04-03 22:16

Mindfoo
 2009-04-04 20:34
#120292 #120292
User since
2009-04-03
10 Artikel
BenutzerIn
[default_avatar]
hab gelöst:

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
sub getxmpp {
    my $mech = WWW::Mechanize->new( cookie_jar => {} );
    $mech->agent_alias( 'Windows IE 6' );
    $mech->add_header('Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8' );
    $mech->add_header('X-Requested-With' => 'XMLHttpRequest' );
    my ( $self, $event ) = @_;
    my $nick = shift;

    my $loginpost = $mech->post(
        'http://www.quakelive.com/user/login',
        {
            u => 'user@mail.com',
            p => 'passwort',
            r => '0',
        }
    );
    $mech->get("http://www.quakelive.com/user/load");
    my $site = $mech->content();
    if($site =~/USERNAME":"(.+)","XAID":"(.+)","STATUS/){
        push(@xmppdata,("$1","$2"));
    } else {
        print "Fail!\n$site";
        exit;
    }
}

sub xmppconnect {
        use constant USER => $xmppdata[0];
        use constant PASS => $xmppdata[1];
        my $connection = Net::XMPP::Client->new();
        $connection->Connect( hostname => 'xmpp.quakelive.com') or die "Cannot connect ($!)\n";
        my @result = $connection->AuthSend( "username" => USER, "password" => PASS, "ressource" => 'quakelive');
        if (!defined($result[0])) {
                print "Authed with XMPP server as user $xmppdata[0] with password $xmppdata[1]\n";
        } else {
                die "Ident/Auth with server failed: $result[0] - $result[1]\n";
        }
        $connection->PresenceSend();
        my $message = Net::XMPP::Message->new();
        $message->SetMessage(
                "to"           => 'Mindfoo\@xmpp.quakelive.com',
                "type"         => "chat",
                "body"         => "testmsg from script");
        $connection->Send($message) or die "Cant send msg!\n";
        sleep(1);

        $connection->Disconnect();
}

View full thread undefined value as a HASH reference - problem