Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $xmlstring = "<?xml version='1.0' encoding='UTF-8' ?>
- <TELEMESSAGE>
- <TELEMESSAGE_CONTENT>
- <MESSAGE>
- <MESSAGE_INFORMATION>
- <SUBJECT></SUBJECT>
- </MESSAGE_INFORMATION>
- <USER_FROM>
- <CIML>
- <NAML>
- <LOGIN_DETAILS>
- <USER_NAME>username</USER_NAME>
- <PASSWORD>password</PASSWORD>
- </LOGIN_DETAILS>
- </NAML>
- </CIML>
- </USER_FROM>
- <MESSAGE_CONTENT>
- <TEXT_MESSAGE>
- <MESSAGE_INDEX>0</MESSAGE_INDEX>
- <TEXT>TEST MESSAGE</TEXT>
- </TEXT_MESSAGE>
- </MESSAGE_CONTENT>
- <USER_TO>
- <CIML>
- <DEVICE_INFORMATION>
- <DEVICE_TYPE DEVICE_TYPE='SMS'/>
- <DEVICE_VALUE>7707070</DEVICE_VALUE>
- </DEVICE_INFORMATION>
- </CIML>
- </USER_TO>
- </MESSAGE>
- </TELEMESSAGE_CONTENT>
- <VERSION>1.6</VERSION>
- </TELEMESSAGE>";
- //creating header for http post request
- $myHeader = array(
- "MIME-Version: 1.0",
- "Content-type: text/xml; charset=utf-8"
- );
- //creating and initiating curl
- $ch = curl_init();
- //setting curl/http headers
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlstring);
- curl_setopt($ch, CURLOPT_URL, "http://bulkmessage.com.mv/partners/xmlMessage.jsp");
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $myHeader);
- //executing http request and getting response. $postResult will contain response xml from TeleMessage.
- $postResult = curl_exec($ch);
- //dd($postResult);
- if (curl_errno($ch)) {
- return null;
- /*
- * for PHP5 you can throw Exception:
- * throw new Exception("Error while sending");
- */
- }
- curl_close($ch);
- $xmlPostResult = simplexml_load_string($postResult);
- $apimsgid = $xmlPostResult->TELEMESSAGE_CONTENT->RESPONSE->MESSAGE_ID;
- $apimsgkey = $xmlPostResult->TELEMESSAGE_CONTENT->RESPONSE->MESSAGE_KEY;
- $response = $xmlPostResult->TELEMESSAGE_CONTENT->RESPONSE->RESPONSE_STATUS;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement