2016-07-26 9 views
0

Ich habe einmal Web-Service-Datei für Get Contact Data erstellen, kann aber nicht String Wort nach dieser Zeile $ httpc = neue HTTP_CLIENT() -Objekt. Ich bin Anruffunktion konnte aber nicht nach $ httpc = new HTTP_CLIENT() diese LinieWelche Datei enthält Webservice-Datei in vtigerCRM?

class Contacts_Contactwebservie_Model extends Vtiger_Module_Model { 
    /** 
    * Function to get the Quick Links for the module 
    * @param <Array> $linkParams 
    * @return <Array> List of Vtiger_Link_Model instances 
    */ 

    public function Contactwebservie(){ 

     global $adb; 

     $endpointUrl = "http://localhost/vtigercrm1/webservice.php"; 
     $userName="admin123"; 
     $userAccessKey = '2j1e7JeYJG20HaIU'; 

     $httpc = new HTTP_CLIENT(); 
     echo "string"; exit(); 
     //getchallenge request must be a GET request. 
     $httpc->GET($endpointUrl."?operation=getchallenge&username=".$userName); 


     $response = $httpc->currentResponse(); 
     //decode the json encode response from the server. 
     $jsonResponse = Zend_JSON::decode($response['body']); 

     //check for whether the requested operation was successful or not. 
     if($jsonResponse['success']==false) 
      //handle the failure case. 
      die('getchallenge failed:'.$jsonResponse['error']['errorMsg']); 

     //operation was successful get the token from the reponse. 
     $challengeToken = $jsonResponse['result']['token']; 
     //create md5 string concatenating user accesskey from my preference page 
     //and the challenge token obtained from get challenge result. 
     $generatedKey = md5($challengeToken.$userAccessKey); 

     //getchallenge request must be a GET request. 
     $httpc->post("$endpointUrl", 
         array('operation'=>'login', 'username'=>$userName, 'accessKey'=>$generatedKey), true); 
     $response = $httpc->currentResponse(); 


     //decode the json encode response from the server. 
     $jsonResponse = Zend_JSON::decode($response['body']); 

     echo "<pre>"; print_r($jsonResponse); exit(); 

     //operation was successful get the token from the reponse. 
     if($jsonResponse['success']==false) 
      //handle the failure case. 
      die('login failed:'.$jsonResponse['error']['errorMsg']); 

     //login successful extract sessionId and userId from LoginResult to it can used for further calls. 
     $sessionId = $jsonResponse['result']['sessionName']; 
     $userId = $jsonResponse['result']['userId']; 

     $currency_id=1; 
     $params = array('description'=>$description,'subject'=>$subject,'quotestage'=>$quotestage,'assigned_user_id'=>'2x'.$assigned_user_id,'account_id'=>'3x'.$account_id,'cf_682'=>$offerlanguage,'currency_id'=>'21x'.$currency_id,'taxtype'=>'group','cf_683'=>$date_submission,'cf_684'=>$date_decision,'cf_685'=>$date_start,'cf_766'=>$winningchance); 

     $urlArgs = "?&total=".$totalamount; 
     //encode the object in JSON format to communicate with the server. 
     $objectJson = Zend_JSON::encode($params); 
     //name of the module for which the entry has to be created. 
     $moduleName = 'Contacts'; 
     //sessionId is obtained from loginResult. 
     $params = array("sessionName"=>$sessionId, "operation"=>'vtws_customfunction', "element"=>$objectJson, "elementType"=>$moduleName); 
     //Create must be POST Request. 
     $httpc->post($endpointUrl.$urlArgs, $params, true); 
     $response = $httpc->currentResponse(); 
     //decode the json encode response from the server. 
     $jsonResponse = Zend_JSON::decode($response['body']); 

     $savedObject = $jsonResponse['result']; 
     $id = $savedObject['id']; 

     $id=str_replace("13x", "", $id); 

     echo $id." offer: ".$subject." created for amount ".$totalamount." for customer: ".$account_id." assigned to: ".$assigned_user_id; 

     return $id; 

    } 
} 

?> 

Antwort

0

Für Webservice ausführen können Sie Ihre eigenen Web-Service in Ihrem vtiger forlder/soap/customerportal.php erstellen

Verwandte Themen