我有PORTECH MV-370(http://www.portech.com.tw/p3-product1_1.asp?Pid=13),我需要发送短信脚本(python,php,java或其他)。使用AT-COMMANDS我已成功发送了一些短信。 我的问题是我没有收到portech mv-370的任何回复,有时也没有启动短信发送
如果我使用网络界面,我发送的所有短信都会成功。 有时脚本没有。
$xusername=SMS_USER_PORTECH;
$xhost=SMS_HOST_PORTECH;
$xpassword=SMS_PASS_PORTECH;
$myoutput = "";
$fp = fsockopen("$xhost", 23, $errno, $errstr, 30);
if (!$fp) {
return "$errstr ($errno)<br />\n";
}
sleep(2);
$cmd = "$xusername\r";
fputs($fp, $cmd, strlen($cmd));
sleep(1);
$cmd = "$xpassword\r";
fputs($fp, $cmd, strlen($cmd));
sleep(1);
$cmd = "module\r";
fputs($fp, $cmd, strlen($cmd));
sleep(2);
$cmd = "ate1\r";
fputs($fp, $cmd, strlen($cmd));
sleep(1);
$cmd = "AT+CSCS=\"GSM\"\r";
fputs($fp, $cmd, strlen($cmd));
sleep(2);
//Select SMS Message Format... (0=PDU Mode, 1=Text Mode)
$cmd = "at+cmgf=1\r";
fputs($fp, $cmd, strlen($cmd));
$myoutput .= fread($fp, 256);
sleep(2);
//Send SMS Message...
$cmd = "at+cmgs=\"$address\"\r";
fputs($fp, $cmd, strlen($cmd));
sleep(2);
$myoutput .= fread($fp, 256);
//Body...
$cmd = "$xbody\r\x1a"; //Ctrl-Z
fputs($fp, $cmd, strlen($cmd));
$res = " ";
$myoutput = "";
$info = stream_set_timeout($fp, 5); //5 seconds read timeout
while ($res != "")
{
$res = fread($fp, 256);
$myoutput .= $res;
}
fclose($fp);
if ($info['timed_out']) {
$status=false;
}
else $status=true;
答案 0 :(得分:0)
Megan from Twilio here.
You can send SMS in the language of your choice using one of these helper libraries. My personal favorite is Python.
# Download the twilio-python library from http://twilio.com/docs/libraries
from twilio.rest import TwilioRestClient
# Find these values at https://twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXX"
auth_token = "YYYYYYYYYYYYYYYYYY"
client = TwilioRestClient(account_sid, auth_token)
message = client.messages.create(to="+12316851234", from_="+15555555555",
body="Hello there!")
And if you need advice on bridging with Portech check out this post.
Hope this is helpful.