0
我是新的處理肥皂API請求響應,我需要幫助來實現使用SMS網關API的SMS代碼。 我使用PHP與通過以下短信網關API發送短信捲曲的要求就是我的代碼發送短信到客戶(S)肥皂客戶端API整合PHP不起作用
<?php
define("USERNAME","#username#");
define("PASSWORD","#password#");
$soapUrl = "soap_wsdl_url";
$xml_post_string = '<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:templateSMS" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="urn:ElbaridTNS" xmlns:ns3="namespace" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header>
<ns3:AuthHeader>
<username>USERNAME</username>
<password>PASSWORD</password>
</ns3:AuthHeader>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:templateSMS>
<Sms xsi:type="ns2:Sms"><phoneNumber xsi:type="xsd:string">phoneNumber</phoneNumber>
<message xsi:type="xsd:string">Hello User, this is test SMS message. We can successfully send SMS.</message>
<unicodeMessage xsi:type="xsd:string">test SMS</unicodeMessage>
<sms_type_id xsi:type="xsd:string">1</sms_type_id>
<notify xsi:type="xsd:string">0</notify>
<senderId xsi:type="xsd:string">SENDERID</senderId>
<priority xsi:type="xsd:string">2</priority>
<vbApp xsi:type="xsd:string">SoapRequest</vbApp>
<vbIdTime xsi:type="xsd:string">20161130101112</vbIdTime>
<destinationPort xsi:type="xsd:string">-1</destinationPort></Sms>
</ns1:templateSMS>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>';
$headers = array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: templateSMS",
"Content-length: ".strlen($xml_post_string),
);
$url = $soapUrl;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
//curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlRequest);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
echo $response;
$response1 = str_replace("<soap:Body>","",$response);
$response2 = str_replace("</soap:Body>","",$response1);
$parser = simplexml_load_string($response2);
echo $parser['resultCode'];
echo "<pre>";
print_r($parser);
echo "</pre>";
curl_close($ch);
?>
我得到了$解析器[「resultCode爲」] 這個響應「發送單播消息「。我不知道這個迴應是什麼意思。自從2天以來,我在這個問題上做了R & Ds,但沒有取得任何成功。
任何人都可以幫助我解決上述問題嗎?
您的代碼從不檢查curl_exec是否返回false。如果它返回,你還應該調用[curl_error](http://php.net/manual/en/function.curl-error.php) – Dragos
由於該消息位於從API接收的SOAP響應中,唯一能夠澄清這些含義的技術支持來自相應的SOAP API服務。 – Dragos
我已經聯繫支持團隊,他們給了我一個應該在請求中傳遞的示例數據。 –