下面的代码是我的PHP解决方案,使用SOAP
并且工作正常,现在我想在NodeJs
上实现,但是我不能在用/sendsms
打开网址之后没有任何结果。这个肥皂用于发送短信,在得到空的结果后,我没有得到任何短信
public static function SendREST($username, $password, $Source, $Destination, $MsgBody, $Encoding)
{
$URL = "http://URL/sendsms";
$msg = urlencode(trim($MsgBody));
$url = $URL . '?username=' . $username . '&password=' . $password . '&source=' . $Source . '&destination=' . $Destination . '&message=' . $msg;
$headers[] = 'Accept: text/html';
$headers[] = 'Connection: Keep-Alive';
$headers[] = 'Content-type: application/x-www-form-urlencoded;charset=UTF-8';
$process = curl_init($url);
curl_setopt($process, CURLOPT_HTTPHEADER, $headers);
curl_setopt($process, CURLOPT_HEADER, 0);
curl_setopt($process, CURLOPT_TIMEOUT, 30);
curl_setopt($process, CURLOPT_RETURNTRANSFER, true);
curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1);
return curl_exec($process);
try {
$return = curl_exec($process);
if ($return) {
return true;
}
} catch (Exception $ex) {
return false;
}
}
我的NodeJs解决方案(数据是假的):
var soap = require('soap');
var url = 'http://URL/sendsms';
var args = {username: '5280',password:'3310AZa',source:'08888735280',destination:'97823036569',message:'SHOOOOOOT !!'};
app.get('/sendsms', function (req, res) {
soap.createClient(url, function (err, client) {
});
});