哪个文件包含vtigerCRM中的webservice文件?

时间:2016-07-26 09:06:37

标签: vtiger vtigercrm

我创建了一次获取联系人数据的Web服务文件,但在此行$ httpc = new HTTP_CLIENT()对象之后不能字符串字。我是调用函数但在$ httpc = new HTTP_CLIENT()此行之后无法执行

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;

    }
}

?>

1 个答案:

答案 0 :(得分:0)

对于网络服务,您可以在vtiger forlder / soap / customerportal.php中创建自己的网络服务