mirror of
https://github.com/fhem/fhem-mirror.git
synced 2024-11-25 11:49:51 +00:00
add: contrib/99_Utils_GoogleTalk.pm
versendet Messages per GoogleTalk, zb aufs Handy git-svn-id: https://svn.fhem.de/fhem/trunk@2615 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
618987d581
commit
c905a808c8
64
fhem/contrib/99_Utils_GoogleTalk.pm
Normal file
64
fhem/contrib/99_Utils_GoogleTalk.pm
Normal file
@ -0,0 +1,64 @@
|
||||
##############################################
|
||||
# $Id:$
|
||||
##########################################################
|
||||
# GoogleTalk
|
||||
# Nachricht mittles GoogleTalk auf ein Android-Smartphone
|
||||
|
||||
package main;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use POSIX;
|
||||
|
||||
sub
|
||||
Utils_GoogleTalk_Initialize($$)
|
||||
{
|
||||
my ($hash) = @_;
|
||||
}
|
||||
|
||||
sub GoogleTalk($) {
|
||||
|
||||
my ($message) = @_;
|
||||
|
||||
Log (3, "GoogleTalk \"" . $message . "\"");
|
||||
|
||||
use Net::XMPP;
|
||||
my $conn = Net::XMPP::Client->new;
|
||||
|
||||
# individuelles Google-Konto zum Versenden
|
||||
my $username = '<username>';
|
||||
my $domain = 'gmail.com';
|
||||
my $password = '<mypass>';
|
||||
|
||||
# individuelles Google-Konto zum Empfangen
|
||||
my $recipient = '<empfaenger@gmail.com>';
|
||||
|
||||
my $resource = 'FHEM';
|
||||
|
||||
my $status = $conn->Connect(
|
||||
hostname => 'talk.google.com',
|
||||
port => 5222,
|
||||
componentname => $domain,
|
||||
connectiontype => 'tcpip',
|
||||
tls => 1,
|
||||
);
|
||||
|
||||
die "Connection failed: $!" unless defined $status;
|
||||
my ($res,$msg) = $conn->AuthSend(
|
||||
username => $username,
|
||||
password => $password,
|
||||
resource => $resource,
|
||||
);
|
||||
|
||||
die "Auth failed ", defined $msg ? $msg : '', " $!" unless defined $res and $res eq 'ok';
|
||||
$conn->MessageSend(
|
||||
to => $recipient,
|
||||
resource => $resource,
|
||||
subject => 'message via ' . $resource,
|
||||
type => 'chat',
|
||||
body => $message,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
1;
|
Loading…
Reference in New Issue
Block a user