Hehe well spotted - serves me right for writing it so fast :)
Mar 12, 2003, 3:22 AM
User (57 posts)
Mar 12, 2003, 3:22 AM
Post #27 of 36
Views: 7748
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();
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();
May 6, 2003, 11:50 PM
New User (2 posts)
May 6, 2003, 11:50 PM
Post #31 of 36
Views: 7657
Let me continue the discussion....
#!/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
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
May 6, 2003, 11:59 PM
Enthusiast (760 posts)
May 6, 2003, 11:59 PM
Post #32 of 36
Views: 7574
Do you mean like hard-code number into script:
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
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
May 7, 2003, 12:47 AM
Enthusiast (760 posts)
May 7, 2003, 12:47 AM
Post #34 of 36
Views: 7617
You could add the following at the beginning of the main SUB:
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
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
May 7, 2003, 12:53 AM
Enthusiast (760 posts)
May 7, 2003, 12:53 AM
Post #36 of 36
Views: 7532
No fair, it's 1:00 am here, and you are waking refreshed and anew
Revised: error_handler if ($number !~ m/^\d+$/);
----
Cheers,
Dan
Founder and CEO
LionsGate Creative
GoodPassRobot
Magelln
Revised: error_handler if ($number !~ m/^\d+$/);
----
Cheers,
Dan
Founder and CEO
LionsGate Creative
GoodPassRobot
Magelln