Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * RemoteViciOutBase
- */
- class RemoteViciOutBase
- {
- protected $phoneNumber;
- protected $jsonMessage;
- protected $ip_address;
- protected $additionalParameters = array();
- const SERVER_IP_ADDDRESS = '111.111.111.111';//replaced with fake IP , this code is publicly available
- function __construct($phoneNumber) {
- $this->setPhoneNumber($phoneNumber);
- }
- /**
- * Additional parameters to be sent to 111.111.111.111 dialer
- *
- * @return mixed Parameters to be prepended
- */
- public function getAdditionalParameters() {
- return $this->additionalParameters;
- }
- /**
- * Sets the additional parameters to be prepended
- *
- * @param Mixed $newadditionalParameters Parameters to be prepended
- */
- public function setAdditionalParameters($additionalParameters) {
- $this->additionalParameters = $additionalParameters;
- return $this;
- }
- public function setIpAddress($ip_address)
- {
- $this->ip_address = $ip_address;
- }
- public function getIpAddress()
- {
- return $this->ip_address;
- }
- /**
- * Retrieves json message
- *
- * @return string jsonMessage
- */
- public function getJsonMessage() {
- return $this->jsonMessage;
- }
- /**
- * Sets value of jsonMessage
- *
- * @param string $jsonMessage json message
- * @return $this
- */
- public function setJsonMessage($jsonMessage) {
- $this->jsonMessage = $jsonMessage;
- return $this;
- }
- /**
- * Retrieves phonenumber
- *
- * @return string phonenumber
- */
- public function getPhoneNumber() {
- return $this->phoneNumber;
- }
- /**
- * Set value of phonenumber
- *
- * @param $phoneNumber
- * @internal param String $newphoneNumber Phonenumber
- * @return $this
- */
- public function setPhoneNumber($phoneNumber) {
- $this->phoneNumber = doubleval($phoneNumber);
- return $this;
- }
- /**
- * Basic http parameter
- * <pre>
- * source=dncadding&user=apiuserwill&pass=mentalapipassword&function=add_mednc&dnc_check=Y&phone_number=07321654987
- * </pre>
- * @param $httpParams
- * @return mixed
- * @throws Exception
- */
- public function sendToRemoteServer($httpParams){
- if (!isset($httpParams['phone_number'])) {
- throw new Exception("Please provide mobile number parameter");
- }
- $curlURL = "http://".RemoteViciOutBase::SERVER_IP_ADDDRESS."/vicidial/non_agent_api.php?";
- $curlURL .= http_build_query($httpParams);
- $curlres = curl_init($curlURL);
- curl_setopt($curlres, CURLOPT_RETURNTRANSFER, true);
- return curl_exec($curlres);
- }
- }
- /*Sub class for 5press*/
- class ViciPressRemote extends RemoteViciOutBase
- {
- public function send()
- {
- $httpParameters = array(
- "source"=>"5press",
- "user"=>"replacedWithFakeUsername",
- "pass"=>"replacedWithFakePassword",
- "function"=>"add_lead",
- "phone_number"=>$this->getPhoneNumber(),
- "phone_code"=>"44",
- "list_id"=>"5555",
- "dnc_check"=>"Y",
- "duplicate_check"=>"DUPLIVE",
- "add_to_hopper"=>"Y",
- "hopper_priority"=>"45",
- );
- $httpParameters = array_merge($httpParameters, $this->getAdditionalParameters());
- $res = $this->sendToRemoteServer($httpParameters);
- $jsonMessage['vici_res'] = $res;
- return $jsonMessage;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement