diff --git a/oraclesoapapi.php b/oraclesoapapi.php
index 7595eec..b9f9b00 100644
--- a/oraclesoapapi.php
+++ b/oraclesoapapi.php
@@ -1,6 +1,7 @@
interfaceId = $interfaceId;
$this->interfaceName = $interfaceName;
$this->error = false;
+ $this->error_curl = false;
+ $this->httpcode = false;
+ $this->retry = false;
$this->clientTransactionID = 0;
$this->chatSessionToken = false;
$this->sitename = false;
@@ -151,7 +155,25 @@ public function requestChat($phonenumber, $data){
$this->setChatSessionToken($chat_soap['chat_token']);
$request_chat = $this->call('RequestChat', $data);
if($this->error){
- //echo $this->error;
+ return false;
+ }else{
+ $request_chat = $this->parseResult('RequestChat', $request_chat);
+ return $request_chat['session_id'];
+ }
+ }// end function
+
+ /**
+ * REQUEST CHAT ONLY
+ *
+ * This function will only perform the RequestChat SOAP API call.
+ *
+ * @param string $phonenumber, array $data
+ *
+ * @return: string $session_id on success, false on failure
+ **/
+ public function requestChatOnly($phonenumber, $data){
+ $request_chat = $this->call('RequestChat', $data);
+ if($this->error){
return false;
}else{
$request_chat = $this->parseResult('RequestChat', $request_chat);
@@ -186,11 +208,32 @@ public function resumeChat($phonenumber, $data){
*
* @param string $msg
*
- * @return: true
+ * @return: boolean
**/
public function sendMsg($msg){
$post_message = $this->call('PostChatMessage', array('Body'=>$msg));
- return true;
+ if(!$post_message){
+ return false;
+ }else{
+ return true;
+ }
+ }// end function
+
+ /**
+ * CHECK ACTIVE CHAT
+ *
+ * This function will check if a chat is still active and available.
+ *
+ * @return: boolean
+ **/
+ public function checkActiveChat(){
+ $post = array('Mode'=>'LISTENING');
+ $post_message = $this->call('SendActivityChange', $post);
+ if(!$post_message){
+ return false;
+ }else{
+ return true;
+ }
}// end function
/**
@@ -200,7 +243,7 @@ public function sendMsg($msg){
*
* @param boolean $typing
*
- * @return: true
+ * @return: boolean
**/
public function setTypingMessage($typing){
if($typing){
@@ -209,7 +252,11 @@ public function setTypingMessage($typing){
$post = array('Mode'=>'LISTENING');
}
$post_message = $this->call('SendActivityChange', $post);
- return true;
+ if(!$post_message){
+ return false;
+ }else{
+ return true;
+ }
}// end function
/**
@@ -292,6 +339,9 @@ public function getSoapRequest($action, $params){
}
if(array_key_exists('LastName', $params['CustomerInformation'])){
$raw_xml .= ''.$params['CustomerInformation']['LastName'].'';
+ }
+ if(array_key_exists('ContactID', $params['CustomerInformation'])){
+ $raw_xml .= '';
}
$raw_xml .= ''.$this->interfaceName.'';
$raw_xml .= '';
@@ -320,7 +370,7 @@ public function getSoapRequest($action, $params){
case 'SendActivityChange':
$raw_xml .= ''.$this->getTransactionRequestData();
- $raw_xml .= ''.$params['Mode'].'';
+ $raw_xml .= ''.$params['Mode'].'';
break;
case 'GetChatOperatingHours':
@@ -427,6 +477,7 @@ public function parseResult($action, $response){
**/
public function call($action, $params, $request = false){
$this->error = false;
+ $this->error_curl = false;
if(!$request){
$this->request = $this->getSoapRequest($action, $params);
}else{
@@ -447,17 +498,27 @@ public function call($action, $params, $request = false){
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_URL, $this->wsdl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_TIMEOUT, 10);
+ curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->request);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
+ if(!$response){
+ $this->error_curl = curl_error($ch);
+ }
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if($http_code == 200){
+ $this->retry = false;
return $this->decodeGzip($response);
+ }elseif(empty($http_code) && !$this->retry){
+ $this->retry = true;
+ sleep(500000);
+ return $this->call($action, $params, $request);
}else{
+ $this->retry = false;
+ $this->httpcode = $http_code;
$this->error = $this->decodeGzip($response);
return false;
}
@@ -481,4 +542,14 @@ public function decodeGzip($response){
}
}// end function
+ /**
+ * GET ERROR
+ *
+ * This function will return the error output.
+ *
+ * @return: string
+ **/
+ public function getError(){
+ return $this->error;
+ }// end function
}// end class