Advertisement
kebyang1511

Untitled

Feb 3rd, 2016
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.52 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * RemoteViciOutBase
  5. */
  6. class RemoteViciOutBase
  7. {
  8.  
  9. protected $phoneNumber;
  10. protected $jsonMessage;
  11. protected $ip_address;
  12. protected $additionalParameters = array();
  13. const SERVER_IP_ADDDRESS = '111.111.111.111';//replaced with fake IP , this code is publicly available
  14.  
  15.  
  16. function __construct($phoneNumber) {
  17. $this->setPhoneNumber($phoneNumber);
  18. }
  19.  
  20. /**
  21. * Additional parameters to be sent to 111.111.111.111 dialer
  22. *
  23. * @return mixed Parameters to be prepended
  24. */
  25. public function getAdditionalParameters() {
  26. return $this->additionalParameters;
  27. }
  28.  
  29. /**
  30. * Sets the additional parameters to be prepended
  31. *
  32. * @param Mixed $newadditionalParameters Parameters to be prepended
  33. */
  34. public function setAdditionalParameters($additionalParameters) {
  35. $this->additionalParameters = $additionalParameters;
  36.  
  37. return $this;
  38. }
  39.  
  40. public function setIpAddress($ip_address)
  41. {
  42. $this->ip_address = $ip_address;
  43. }
  44.  
  45. public function getIpAddress()
  46. {
  47. return $this->ip_address;
  48. }
  49.  
  50.  
  51. /**
  52. * Retrieves json message
  53. *
  54. * @return string jsonMessage
  55. */
  56. public function getJsonMessage() {
  57. return $this->jsonMessage;
  58. }
  59.  
  60. /**
  61. * Sets value of jsonMessage
  62. *
  63. * @param string $jsonMessage json message
  64. * @return $this
  65. */
  66. public function setJsonMessage($jsonMessage) {
  67. $this->jsonMessage = $jsonMessage;
  68. return $this;
  69. }
  70.  
  71.  
  72. /**
  73. * Retrieves phonenumber
  74. *
  75. * @return string phonenumber
  76. */
  77. public function getPhoneNumber() {
  78. return $this->phoneNumber;
  79. }
  80.  
  81. /**
  82. * Set value of phonenumber
  83. *
  84. * @param $phoneNumber
  85. * @internal param String $newphoneNumber Phonenumber
  86. * @return $this
  87. */
  88. public function setPhoneNumber($phoneNumber) {
  89. $this->phoneNumber = doubleval($phoneNumber);
  90. return $this;
  91. }
  92.  
  93. /**
  94. * Basic http parameter
  95. * <pre>
  96. * source=dncadding&user=apiuserwill&pass=mentalapipassword&function=add_mednc&dnc_check=Y&phone_number=07321654987
  97. * </pre>
  98. * @param $httpParams
  99. * @return mixed
  100. * @throws Exception
  101. */
  102. public function sendToRemoteServer($httpParams){
  103. if (!isset($httpParams['phone_number'])) {
  104. throw new Exception("Please provide mobile number parameter");
  105. }
  106. $curlURL = "http://".RemoteViciOutBase::SERVER_IP_ADDDRESS."/vicidial/non_agent_api.php?";
  107. $curlURL .= http_build_query($httpParams);
  108. $curlres = curl_init($curlURL);
  109. curl_setopt($curlres, CURLOPT_RETURNTRANSFER, true);
  110. return curl_exec($curlres);
  111. }
  112.  
  113. }
  114. /*Sub class for 5press*/
  115. class ViciPressRemote extends RemoteViciOutBase
  116. {
  117. public function send()
  118. {
  119. $httpParameters = array(
  120. "source"=>"5press",
  121. "user"=>"replacedWithFakeUsername",
  122. "pass"=>"replacedWithFakePassword",
  123. "function"=>"add_lead",
  124. "phone_number"=>$this->getPhoneNumber(),
  125. "phone_code"=>"44",
  126. "list_id"=>"5555",
  127. "dnc_check"=>"Y",
  128. "duplicate_check"=>"DUPLIVE",
  129. "add_to_hopper"=>"Y",
  130. "hopper_priority"=>"45",
  131. );
  132. $httpParameters = array_merge($httpParameters, $this->getAdditionalParameters());
  133. $res = $this->sendToRemoteServer($httpParameters);
  134. $jsonMessage['vici_res'] = $res;
  135. return $jsonMessage;
  136. }
  137. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement