我正在写一个短信应用程序,它从MYSQL数据库中检索消息并使用cURL将消息传递给短信网关的smpp api。我发现了一个小问题cURL ...从消息被截断的意义上说,我通过使用urlencode为我正在传输的变量添加了更多数据...但是有些数据仍然被截断。我被告知这可能是因为的长度“GET” request..however我相信访问SMS网关API的唯一途径是通过“GET”请求......基于我是given..which是:cURL仍然截断数据...即使使用url编码
http://xxx.yyy.zzz.qqq:8080/bulksms/bulksms?username=
bbb&password=demo&type=0&dlr=Z&destination=806754367
&source=TESTING&message=hi testing
这个应用程序的目的是发送stude的学术报告NTS他们的监护人......因此请求必须是从表中取lengthy.An平均记录是这样的:
The Results For Your Son Pedro Have Been Released As Follows:
Mathematics:97% English Language:58% Crk:59% Social Studies:67%
Commerce:67% Government98% Biology: 100% Chemistry:78% Geography:99%
Religious Knowledge:Did Not Register
Economics:54%
当我传递的记录,卷曲试运行,这是我得到了什么:
The Results For Your Son Pedro Have Been Released As Follows:
Mathematics:97% English Language:58% Crk:59% Social Studi
所以,我关心的是获得“完全”记录,然后将其发送到与进行urlencode功能短信网关api.My修改后的代码:
<?php
include 'sms_connect.php';
$sql="select name from sms";
$result=mysqli_query($link,$sql) or die("Error in sms".mysqli_error($link));
while($row=mysqli_fetch_assoc($result))
{$name=$row['name'];
$url = "http://localhost/sms/index.php?name=".urlencode($name);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
// grab URL and pass it to the browser
$results = curl_exec($ch);
var_dump($results);
}
curl_close($ch);
?>
好吧......技术支持人短信网关表示,随着smpp协议..大量的数据可以发送..我打算试验和缩写适当的数据。 我的index.php代码如下所示:
$name=$_GET['name'];
include 'sms_connect.php';
$sql="insert into sms_test values('$name')";
$result=mysqli_query($link,$sql)
or die("Error in inserting name".mysqli_error($link));
我们不能没有任何代码帮助;) – str
尝试网址编码,以便将空格替换为'%20'等。 – arma
您的代码非常混乱。真的,你在开始时有任意数量的空间字符? – hsz