I am new for lwp pls help me in my code
This code for send sms in thailand
Sorry For My poor English.

Best Regards.

#!/usr/bin/perl 

print "Pragma: no-cache\n";
print "Content-type: text/html\n\n";

#### Post Login ####
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
$ua = LWP::UserAgent->new();
my $req = POST 'https://sonic2.tac.co.th/bp3/bin/Login',
[
inputUserName =>'Username', 
inputPassword =>'Password',
inputOK =>'???????????' 
];
$ua ->agent('Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)');
$req ->header('Accept' => 'iimage/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*');
$req ->header('Accept-Language' => "th");
$req ->referer("https://sonic2.tac.co.th/bp3/bin/Index";);
$content = $ua->request($req)->as_string;

$location = $content;
$location =~ s{(.*)Location: (.*?)\n(.*)}{$2}sgi; 
$WLSESERVICE = $content;
$WLSESERVICE =~ s{(.*)Set-Cookie: WLSESERVICE=(.*?);(.*)}{$2}sgi; 

print $content;

#### Get Form To Send ####
use HTTP::Request::Common qw(GET);
use LWP::UserAgent;
$ua = LWP::UserAgent->new();
my $req = GET 'https://sonic2.tac.co.th/bp3/bin/Dspc/WebMessageForm',[];
$ua ->agent('Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)');
$req ->header('Accept' => 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*');
$req ->header('Accept-Language' => "th");
$req ->header('Cookie' => "WLSESERVICE=$WLSESERVICE");
$req ->referer("https://sonic2.tac.co.th/bp3/bin/Dspc/WebMessageForm";);
$content = $ua->request($req)->as_string;

$location = $content;
$location =~ s{(.*)Location: (.*?)\n(.*)}{$2}sgi; 
$WLSESERVICE = $content;
$WLSESERVICE =~ s{(.*)Set-Cookie: WLSESERVICE=(.*?);(.*)}{$2}sgi; 

print $content;

#### Post To Send ####
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
$ua = LWP::UserAgent->new();
my $req = POST 'https://sonic2.tac.co.th/bp3/bin/Dspc/WebMessage',
[
radiobutton =>'radiobutton',
inputMix =>'Message',
inputEng =>'',
inputMul =>'',
phoneNo71 =>'011234567',
inputSubrNumb1 =>'011234567',
phoneNo72 =>'',
inputSubrNumb2 =>'',
phoneNo73 =>'',
inputSubrNumb3 =>'',
phoneNo74 =>'',
inputSubrNumb4 =>'',
phoneNo75 =>'',
inputSubrNumb5 =>'',
inputOK =>'?????????'
];
$ua ->agent('Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)');
$req ->header('Accept' => 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*');
$req ->header('Accept-Language' => "th");
$req ->header('Cookie' => "WLSESERVICE=$WLSESERVICE");
$req ->referer("https://sonic2.tac.co.th/bp3/bin/Dspc/WebMessage";);
$content = $ua->request($req)->as_string;

$location = $content;
$location =~ s{(.*)Location: (.*?)\n(.*)}{$2}sgi; 
$WLSESERVICE = $content;
$WLSESERVICE =~ s{(.*)Set-Cookie: WLSESERVICE=(.*?);(.*)}{$2}sgi; 

print $content;


use HTTP::Request::Common qw(GET);
use LWP::UserAgent;
$ua = LWP::UserAgent->new();
my $req = GET "$location",[];
$req ->referer("https://sonic2.tac.co.th/bp3/bin/Dspc/WebMessage";);
$ua ->agent('Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)');
$req ->header('Accept' => 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*');
$req ->header('Accept-Language' => "th");
$req ->header(Cookie => "WLSESERVICE=$WLSESERVICE");
$content = $ua->request($req)->as_string;

$location = $content;
$location =~ s{(.*)Location: (.*?)\n(.*)}{$2}sgi; 
$WLSESERVICE = $content;
$WLSESERVICE =~ s{(.*)Set-Cookie: WLSESERVICE=(.*?);(.*)}{$2}sgi; 

#### Result After Post Login ####
HTTP/1.1 302 (Found) Moved Temporarily 
Connection: close 
Date: Mon, 29 Jul 2002 17:10:09 GMT 
Location: https://sonic2.tac.co.th/bp3/bin/Dspc/Welcome 
Server: Netscape-Enterprise/4.0 
Content-Length: 237 
Content-Length: 237 
Client-Date: Mon, 29 Jul 2002 17:10:40 GMT 
Client-Response-Num: 1 
Client-SSL-Cert-Issuer: /C=ZA/ST=Western Cape/L=Cape Town/O=Thawte Consulting 
cc/OU=Certification Services Division/CN=Thawte Server 
[EMAIL PROTECTED] 
Client-SSL-Cert-Subject: /C=TH/ST=Bangkok/L=Bangkok/O=Total Access Communication 
PCL./OU=Corporate Information System/CN=sonic2.tac.co.th 
Client-SSL-Cipher: EXP1024-RC4-SHA Client-SSL-Warning: Peer certificate not verified 
Set-Cookie: 
WLSESERVICE=PUV2wyD2BqnFX4aPdUKuIl13DhpnJH5aHbzCqY2kaqyHtMZoUeyG|-789975553483730886/169083237/6/7001/7001/7002/7002/7001/-1;
 path=/ 

This document you requested has moved temporarily.
It's now at /bp3/bin/Dspc/Welcome.

HTTP/1.1 200 OK 
Cache-Control: no-cache 
Connection: close 
Date: Mon, 29 Jul 2002 17:10:11 GMT 
Pragma: No-cache 
Server: Netscape-Enterprise/4.0 
Content-Type: text/html 
Content-Type: text/html; charset=windows-874 
Expires: Thu, 01 Jan 1970 00:00:00 GMT 
Expires: Client-Date: Mon, 29 Jul 2002 17:10:43 GMT 
Client-Response-Num: 1 
Client-SSL-Cert-Issuer: /C=ZA/ST=Western Cape/L=Cape Town/O=Thawte Consulting 
cc/OU=Certification Services Division/CN=Thawte Server 
[EMAIL PROTECTED] 
Client-SSL-Cert-Subject: /C=TH/ST=Bangkok/L=Bangkok/O=Total Access Communication 
PCL./OU=Corporate Information System/CN=sonic2.tac.co.th 
Client-SSL-Cipher: EXP1024-RC4-SHA 
Client-SSL-Warning: Peer certificate not verified Link: ; rel="stylesheet" Title: 

#### Result After Post Send ####

HTTP/1.1 400 (Bad Request) 
Bad request Date: Mon, 29 Jul 2002 17:10:15 GMT 
Server: Netscape-Enterprise/4.0 
Content-Length: 147 
Content-Type: text/html 
Client-Date: Mon, 29 Jul 2002 17:10:47 GMT 
Client-Response-Num: 1 
Client-SSL-Cert-Issuer: /C=ZA/ST=Western Cape/L=Cape Town/O=Thawte Consulting 
cc/OU=Certification Services Division/CN=Thawte Server 
[EMAIL PROTECTED] 
Client-SSL-Cert-Subject: /C=TH/ST=Bangkok/L=Bangkok/O=Total Access Communication 
PCL./OU=Corporate Information System/CN=sonic2.tac.co.th 
Client-SSL-Cipher: EXP1024-RC4-SHA 
Client-SSL-Warning: Peer certificate not verified 
Title: Bad request 

Bad request
Your browser sent a query this server could not understand.

HTTP/1.1 200 OK 
Cache-Control: no-cache 
Connection: close Date: Mon, 29 Jul 2002 17:10:17 GMT 
Pragma: No-Cache 
Server: Netscape-Enterprise/4.0 
Content-Type: text/html 
Content-Type: text/html; charset=windows-874 
Expires: Thu, 01 Jan 1970 00:00:00 GMT 
Client-Date: Mon, 29 Jul 2002 17:10:48 GMT 
Client-Response-Num: 1 
Client-SSL-Cert-Issuer: /C=ZA/ST=Western Cape/L=Cape Town/O=Thawte Consulting 
cc/OU=Certification Services Division/CN=Thawte Server 
[EMAIL PROTECTED] 
Client-SSL-Cert-Subject: /C=TH/ST=Bangkok/L=Bangkok/O=Total Access Communication 
PCL./OU=Corporate Information System/CN=sonic2.tac.co.th 
Client-SSL-Cipher: EXP1024-RC4-SHA 
Client-SSL-Warning: Peer certificate not verified 
Link: ; rel="stylesheet" 
Title: 

Reply via email to