Advertisement
Guest User

Untitled

a guest
Aug 13th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. $xmlstring = "<?xml version='1.0' encoding='UTF-8' ?>
  2. <TELEMESSAGE>
  3. <TELEMESSAGE_CONTENT>
  4. <MESSAGE>
  5. <MESSAGE_INFORMATION>
  6. <SUBJECT></SUBJECT>
  7. </MESSAGE_INFORMATION>
  8. <USER_FROM>
  9. <CIML>
  10. <NAML>
  11. <LOGIN_DETAILS>
  12. <USER_NAME>username</USER_NAME>
  13. <PASSWORD>password</PASSWORD>
  14. </LOGIN_DETAILS>
  15. </NAML>
  16. </CIML>
  17. </USER_FROM>
  18. <MESSAGE_CONTENT>
  19. <TEXT_MESSAGE>
  20. <MESSAGE_INDEX>0</MESSAGE_INDEX>
  21. <TEXT>TEST MESSAGE</TEXT>
  22. </TEXT_MESSAGE>
  23. </MESSAGE_CONTENT>
  24. <USER_TO>
  25. <CIML>
  26. <DEVICE_INFORMATION>
  27. <DEVICE_TYPE DEVICE_TYPE='SMS'/>
  28. <DEVICE_VALUE>7707070</DEVICE_VALUE>
  29. </DEVICE_INFORMATION>
  30. </CIML>
  31. </USER_TO>
  32. </MESSAGE>
  33. </TELEMESSAGE_CONTENT>
  34. <VERSION>1.6</VERSION>
  35. </TELEMESSAGE>";
  36.  
  37. //creating header for http post request
  38. $myHeader = array(
  39. "MIME-Version: 1.0",
  40. "Content-type: text/xml; charset=utf-8"
  41. );
  42. //creating and initiating curl
  43. $ch = curl_init();
  44.  
  45. //setting curl/http headers
  46. curl_setopt($ch, CURLOPT_POST, 1);
  47. curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlstring);
  48. curl_setopt($ch, CURLOPT_URL, "http://bulkmessage.com.mv/partners/xmlMessage.jsp");
  49. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
  50. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  51. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  52. curl_setopt($ch, CURLOPT_HTTPHEADER, $myHeader);
  53. //executing http request and getting response. $postResult will contain response xml from TeleMessage.
  54. $postResult = curl_exec($ch);
  55.  
  56.  
  57. //dd($postResult);
  58. if (curl_errno($ch)) {
  59. return null;
  60. /*
  61. * for PHP5 you can throw Exception:
  62. * throw new Exception("Error while sending");
  63. */
  64. }
  65. curl_close($ch);
  66.  
  67. $xmlPostResult = simplexml_load_string($postResult);
  68. $apimsgid = $xmlPostResult->TELEMESSAGE_CONTENT->RESPONSE->MESSAGE_ID;
  69. $apimsgkey = $xmlPostResult->TELEMESSAGE_CONTENT->RESPONSE->MESSAGE_KEY;
  70. $response = $xmlPostResult->TELEMESSAGE_CONTENT->RESPONSE->RESPONSE_STATUS;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement