NAME
Net::SMS::PChome - Send SMS messages via the sms.pchome.com.tw service.
SYNOPSIS
use strict;
use Net::SMS::PChome;
my $sms = new Net::SMS::PChome;
$sms->login('username', 'password', 'auth_code');
$sms->smsRecipient('0912345678');
$sms->smsSend("The SMS be send by PChome SMS Service!");
if($sms->is_success) {
print "Successfully sent message to ".$sms->successcount." number!\n";
} else {
print "Something went horribly wrong!\n".
"Error: ".$sms->resultmessage." (".$sms->resultcode.")".
}
or, if you like one liners:
perl -MNet::SMS::PChome -e 'send_sms("pchome_username", "pchome_password", "auth_code", "recipient", "messages text")'
DESCRIPTION
Net::SMS::PChome allows sending SMS messages via http://sms.pchome.com.tw/
METHODS
new
new creates a new Net::SMS::PChome object.
Options
- baseurl
-
Defaults to http://sms.pchome.com.tw/jsp/smslong.jsp
- ua
-
Configure your own WWW::Mechanize object, or use our default value.
- username
-
Your pchome.com.tw username
- password
-
Your pchome.com.tw password
- authcode
-
Your PChome Micro Payment System authcode
- smsMessage
-
The actual SMS text
- smsType
-
Defaults to 1, but could be set to 2
1 mean send SMS now. 2 mean send SMS at a delivery date.
- smsEncode
-
Defaults to BIG5, but could be set to ASCII
BIG5: the SMS context in Chinese or Engilsh, the max of SMS context length is 70 character. ASCII: the SMS context in Engilsh, the max of SMS context length is 140 character.
- smsDeliverydate
-
smsDeliverydate mean send SMS at a reserved time.
Its format is YYYYMMDDHHII.
Example: 200607291730 (mean 2006/07/29 17:30)
All these options can be set at creation time, or be set later, like this:
$sms->username('my_username');
$sms->password('my_password');
$sms->smsType('2');
$sms->smsDeliverydate('200608141803'); # Send SMS at 2006/08/14 PM 06:03.
login
Set the username, password and authcode in one go.
$sms->login('my_pchome_username', 'my_pchome_password', 'my_pchome_authcode');
# is basically a shortcut for
$sms->username('my_pchome_username');
$sms->password('my_pchome_password');
$sms->authcode('my_pchome_authcode');
Without arguments, it will return the array containing username, password and authcode.
my ($username, $password, $authcode) = $sms->login();
smsRecipient
Push numbers in the recipients array
foreach(qw/0912345678 0987654321 0912920542/) {
$sms->smsRecipient($_);
}
smsSend
Send the actual message. If this method is called with an argument, it's considered the message. Returns true if the sending was successful, and false when the sending failed (see resultcode and resultmessage).
is_success
Returns true when the last sending was successful and false when it failed.
resultcode
Returns the resulting code.
When LWP::UserAgent reports an error, the resultcode will be set to -999
.
resultmessage
Returns the result message, as provided by sms.pchome.com.tw, or LWP::UserAgent.
EXPORT
send_sms
SEE ALSO
WEBSITE
You can find information about PChome SMS Service at :
http://sms.pchome.com.tw/
AUTHOR
Tsung-Han Yeh, <snowfly@yuntech.edu.tw>
COPYRIGHT AND LICENSE
Copyright (C) 2006 by Tsung-Han Yeh
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.