Net::SMS::PChome - Send SMS messages via the sms.pchome.com.tw service.
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")'
Net::SMS::PChome allows sending SMS messages via http://sms.pchome.com.tw/
new creates a new Net::SMS::PChome object.
Defaults to http://sms.pchome.com.tw/jsp/smslong.jsp
Configure your own WWW::Mechanize object, or use our default value.
Your pchome.com.tw username
Your pchome.com.tw password
Your PChome Micro Payment System authcode
The actual SMS text
Defaults to 1, but could be set to 2
1 mean send SMS now. 2 mean send SMS at a delivery date.
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 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.
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();
Push numbers in the recipients array
foreach(qw/0912345678 0987654321 0912920542/) { $sms->smsRecipient($_); }
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).
Returns true when the last sending was successful and false when it failed.
Returns the resulting code.
When LWP::UserAgent reports an error, the resultcode will be set to -999.
-999
Returns the result message, as provided by sms.pchome.com.tw, or LWP::UserAgent.
send_sms
You can find information about PChome SMS Service at :
http://sms.pchome.com.tw/
Tsung-Han Yeh, <snowfly@yuntech.edu.tw>
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.
To install Net::SMS::PChome, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::SMS::PChome
CPAN shell
perl -MCPAN -e shell install Net::SMS::PChome
For more information on module installation, please visit the detailed CPAN module installation guide.