2011-10-11 59 views
0

我正在写一个短信应用程序,它从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)); 
+2

我们不能没有任何代码帮助;) – str

+0

尝试网址编码,以便将空格替换为'%20'等。 – arma

+0

您的代码非常混乱。真的,你在开始时有任意数量的空间字符? – hsz

回答

1

变化

 $url = "http://localhost/sms/index.php?name=".$name; 

 $url = "http://localhost/sms/index.php?name=".urlencode($name); 

您可以rawurlencode()以及

UPDATE 尝试既然现在你数据,但不是完整的,似乎是问题不在卷曲中,而是在发送请求到(localhost/sms/index.php)的脚本上。 请记住,SMS的大小是有限的,这可能是数据被截断的原因。无论如何,不​​看index.php,我们不能说明你为什么没有收到数据。

+0

好吧...我用作测试运行的脚本位于我的本地主机上。我还没有开始打api,但是我已经包含了它。 – ewom2468

+0

@ ewom2468包含的代码不会生成/输出显示的输出。它只是在数据库中插入一条记录。 –

+0

是的..问题是插入的内容正在被截断,所以我相信正在发送的内容正在被截断 – ewom2468

相关问题