Gossamer Forum
Home : General : Perl Programming :

How do you send an ICQ Pager from a perl script?

(Page 2 of 2)
> >
Quote Reply
Re: [dan] How do you send an ICQ Pager from a perl script? In reply to
Hehe well spotted - serves me right for writing it so fast :)

Last edited by:

Paul: Mar 12, 2003, 2:31 AM
Quote Reply
Re: [Paul] How do you send an ICQ Pager from a perl script? In reply to
well ive found the ICQ.pm modules code and copied and pasted it in and put it in my cgi-bin/Net dir and the script i have put in the cgi-bin goes as follows and it says

failed to open log file
fopen: Permission denied

use CGI::Carp qw/fatalsToBrowser/;
use Net::ICQ;
$uin = 1234567;
$password = "pass";
$icq = Net::ICQ->new($uin, $password);
$icq->connect();
$icq->add_handler('SRV_SYS_DELIVERED_MESS', \&on_msg);
$params = {
'type' => 1,
'text' => 'Hello world',
'receiver_uin' => 1234567
};
$icq->send_event('CMD_SEND_MESSAGE', $params);
$icq->start();
Quote Reply
Re: [WoSkI] How do you send an ICQ Pager from a perl script? In reply to
well my above script wont work and the host emailed me back saying that will not install the modules i need so im stuffed, any more ideas??
Quote Reply
Re: [WoSkI] How do you send an ICQ Pager from a perl script? In reply to
You need to consider a new host if they are refusing to install the perl modules.
Quote Reply
Re: [Paul] How do you send an ICQ Pager from a perl script? In reply to
dont wanna new host
Quote Reply
Re: [dan] How do you send an ICQ Pager from a perl script? In reply to
Let me continue the discussion....
Code:


#!/usr/bin/perl
#======================================
# Copyright Paul 2003.
use strict;
use LWP::UserAgent;
use HTTP::Request::Common qw(GET);
main();
#======================================
sub main {
#-------------------------------------------------------------
# Quick example of ICQ pager.
my $ua = LWP::UserAgent->new( agent => 'Takeshi/1.0', timeout => 30 );
my $url = q|http://wwp.icq.com/scripts/WWPMsg.dll?to=$number&from=me&fromemail=me@here.com&subject=this&body=message|;
my $res = $ua->request( GET $url );
if ($res->is_success) {
print "Content-type: text/html\n\n";
print $res->content;
}
else {
print "Content-type: text/html\n\n";
print $res->code;
}
}


i cant set the $number as a variable in this script
i tried to put $number = "12345"; to the script, but it didnt work
Quote Reply
Re: [zigli] How do you send an ICQ Pager from a perl script? In reply to
Do you mean like hard-code number into script:

Code:


my $number = "1234";

my $url = q|http://wwp.icq.com/scripts/WWPMsg.dll?to=$number&from=me&fromemail=me@here.com&subject=this&body=message|;


... or pass to script via GET or POST?

----
Cheers,

Dan
Founder and CEO

LionsGate Creative
GoodPassRobot
Magelln
Quote Reply
Re: [dan] How do you send an ICQ Pager from a perl script? In reply to
In Reply To:
Do you mean like hard-code number into script:

Code:


my $number = "1234";

my $url = q|http://wwp.icq.com/scripts/WWPMsg.dll?to=$number&from=me&fromemail=me@here.com&subject=this&body=message|;


... or pass to script via GET or POST?

yes, i wanted to set the value of $number via GET/POST
Quote Reply
Re: [zigli] How do you send an ICQ Pager from a perl script? In reply to
You could add the following at the beginning of the main SUB:

Code:
$| = 1;

use CGI;
my $in = new CGI;
my $number = $in->param('number');


Then you can pass number via GET as query: script.cgi?number=1234

or

via POST:

<form action="/cgi-bin/script.cgi" method="POST">
<input type="text" name="number" size="10" maxlength="10" value="1234">
<input type="submit">
</form>

(or pass number as hidden form field if not user-entered)

- you should also add regex to test validity of number - for example:

error_handler if ($number !~ m/d+/);

----
Cheers,

Dan
Founder and CEO

LionsGate Creative
GoodPassRobot
Magelln
Quote Reply
Re: [dan] How do you send an ICQ Pager from a perl script? In reply to
>>
error_handler if ($number !~ m/d+/);
<<

You'll want ^ and $ too.
Quote Reply
Re: [Paul] How do you send an ICQ Pager from a perl script? In reply to
No fair, it's 1:00 am here, and you are waking refreshed and anew Wink

Revised: error_handler if ($number !~ m/^\d+$/);

----
Cheers,

Dan
Founder and CEO

LionsGate Creative
GoodPassRobot
Magelln

Last edited by:

dan: May 7, 2003, 1:01 AM
> >