我正在尝试找到一种方法来使用从 SMS 消息提供程序接收到的检索值,我收到的值是:
0|IN_PROGRESS|225161649
我需要在我的数据库中存储某些值的位置。
这是我收到值的网址:
http://bulksms.2way.co.za:5567/eapi/submission/send_sms/2/2.0?username=xxxx&password=xxxxx&message=Hi+Mom+%26+Dad&msisdn=44423456789
这将返回值:
23|invalid credentials (username was: xxxx)|
现在我需要获取值并存储在 PHP 变量中以处理到我的数据库。
这是我提交数据的表单:
$mobile = $_POST['mobile'];
$text = $_POST['textcounter'];
$username = 'xxxx';
$password = 'xxxx';
// Set Timezone
date_default_timezone_set('Africa/Johannesburg');
$date = date("m/d/y G.i:s", time());
// Create Unique ID
$code = md5(time());
$newid = $code.$clientid;
$sql="INSERT INTO sms_sent (sent_id, sent_message, sent_date, sent_quantity, client_id, sent_mobile)VALUES('$newid', '$text', '$date', '1', '$clientid', '$mobile')";
$result=mysql_query($sql);
$url = "http://bulksms.2way.co.za/eapi/submission/send_sms/2/2.0"; // URL to calc.cgi
$fields = array(
'site'=>'',
'username'=>($username),
'password'=>($password),
'message'=>urlencode($text),
'msisdn'=>urlencode($mobile)
);
$fields_string="?";
//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string,'&');
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
//execute post
ob_start();
curl_exec($ch);
ob_end_clean();
echo '<div class="alert alert-block alert-success">
<a class="close" data-dismiss="alert" href="#">×</a>
<h4 class="alert-heading">Success!</h4>
Your message has been Sent!
</div><br/><br/><a href="search_contact.php" class="btn btn-large btn-round">Search Contact</a>';
//close connection
curl_close($ch);
}
请有任何建议。