简体   繁体   English

如何在没有json响应的情况下在php API中发送短信?

[英]How to send SMS in php API without json response?

I am using following code to send SMS in php API.我正在使用以下代码在 php API 中发送短信。

$ch = curl_init("http://wpsms.whitepearldemo.biz....?user=".$user."&password=".$password."&msisdn=".$msisdn."&sid=".$sid."&msg=".$msg."&fl=".$fl."&gwid=".$gwid);
$result = curl_exec($ch);
curl_close($ch);

Including this response, I also have another response.包括这个回应,我还有另一个回应。 So it looks like所以它看起来像

{
//SMS default response
{"ErrorCode":"000","ErrorMessage":"Success","JobId":"381a80-157cc2142bfa","MessageData":[{"MobileNumber":"919898xxxxxx ","MessageParts":[{"MessageId": "919898xxxxxx -67e3765cdf034f438","MessagePartId":1,"MessageText":"test message"}]}]}
}{
//another response
...
}

When this api called, everything worked properly but app this error -当这个 api 调用时,一切正常,但应用这个错误 -

"onFailer: JSON document was not fully consumed." “onFailer:JSON 文档未完全使用。”

. .

If I comment SMS code temporarily, no error occurs.如果我临时注释短信代码,则不会发生错误。 Can we avoid the response of SMS?我们可以避免短信的回复吗? Please help me to fix it.请帮我修复它。

Let me answer my question...Use following code to send SMS without JSON response.让我回答我的问题...使用以下代码发送没有 JSON 响应的 SMS。

$data = array(
    'user' => $user,
    'password' => $password,
    'msisdn' => $msisdn,
    'sid' => $sid,                          
    'gwid' => $gwid,
    'fl' => $fl,
    'msg' => 'Hi'
        );

    $curl = curl_init('http://wpsms.whitepearldemo......?format=xml');
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $response = curl_exec($curl);
    curl_close($curl);

Thanks & regards.感谢和问候。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM