下面是我的代碼,經過搜索和整夜工作後,我終於想出瞭如何讓它發送短信。問題是我不能在正文消息中留下空格,並且它不顯示$smsmessage
的值。Curl輸出變量名稱而不是其內容
extract($_POST);
$smsmessage1 = "This is the sms that will be sent";
$smsmessage = urlencode($smsmessage1);
//set POST variables
$url = 'http://www.mysmsgateway.com/bulksms/[email protected]&password=123456789&message=$smsmessage&mobile=2348035081907&sender=Boss';
$fields = array();
//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_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
上述代碼發送消息,但將輸出$smsmessage
代替獲取的$smsmessage
從上面的值。
請使用代碼塊把你的代碼......你不會這麼混亂的代碼得到的答覆... – 2011-05-16 07:23:16
編輯,不要抱怨 – 2011-05-16 23:15:28