navin navin - 3 months ago 17
Perl Question

how to send sms to using perl?

Tried below simple ones

code1 using



use strict;
use warnings;
use Net::SMS::WAY2SMS;

my $sms = Net::SMS::WAY2SMS->new(
'user' => 'user_name' ,
'password' => 'secret_password',
'mob' => ['1234567890', '0987654321']
);

# multi line sms
$sms->send(q[testing
sending
sms]);
#end1


No error displayed and not working

code2 using
Net::SMS::160By2


#!C:/strawberry/perl/bin/perl.exe
use strict;
use warnings;
use Net::SMS::160By2;
my $username = "9823763544";
my $password = "sssssss";
my $msg = "Hi";
my $to = "9922334455";
my $obj = Net::SMS::160By2->new($username, $password);
$obj->send_sms($msg, $to);
#end2


Error:can't call method "action" on undefined values at C:/strawberry/perl/site/lib/net/SMS/160By2.pm at line 196.

I have also tried several other scripts and none of them worked

Answer

The reason why Net::SMS::WAY2SMS is not working is the issue with module. There is no standard API being provided by Way2SMS team, and they keep changing their interface. That is why all the Android apps related to Way2SMS also stop working after a month or two (as soon as Way2SMS team changes interface). As long as Way2SMS doesn't provide an API, you'll not get a stable solution.

Same issue with 160By2.

Line 196 of 160By2.pm is $form->action($sendsms_submit_uri); and the error you get is can't call method "action" on undefined values. That means $form is undefined.

In module author has used our $SENDSMS_URL = 'http://160by2.com/FebSendSMS';

$mech here is trying to get the above URL.

my $sendsms_uri = URI->new($SENDSMS_URL);
$mech->get($sendsms_uri->as_string);`

and then at the end it does

my $form = $mech->form_name('frm_sendsms'); and

$form->action($sendsms_submit_uri);

But if you notice the $SENDSMS_URL gives 404 error (This URL doesn't even exist). Hence it gives error.

Comments