php – vTiger Web服务:查询拒绝执行操作的权限

我正在使用vTiger Web服务使用查询来检索包含我的联系人的VtigerObjects数组.我按照这里给出的指示:

https://wiki.vtiger.com/index.php/Webservices_tutorials

到目前为止,我正在获取一个我可以用来登录的挑战令牌,所以它正在工作..但是从我试图通过查询获取数据的那一刻起,我得到以下错误

查询拒绝执行操作的权限”

我是管理员,所以我应该拥有所有权限,对吧?这是我的代码,我希望有人可以帮助我吗?

$username = 'xxxxxxxxxx';
$userAccessKey = 'xXxXxXxXxXxXxX';

//Create HTTP Client and set url and parameters
$client = new Zend_Http_Client();
$client->setUri('https://example.com/webservice.PHP');
$client->setParameterGet(array(
    'operation' => 'getchallenge', 
    'username' => $username
));

// Get Response (and decode)
$response = $client->request('GET');
$jsonResponse = Zend_Json::decode($response->getBody());

// Check if operation was successful
if ($jsonResponse['success'] == false)
    die('getchallenge Failed:'.$jsonResponse['error']['errorMsg']);

// Get token from response
$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);

//Create HTTP Client and set url and parameters
$client->setUri('https://example.com/webservice.PHP');
$client->setParameterPost(array(
    'operation' => 'login',
    'username' => $username,
    'accessKey' => $generatedKey
), true);

// Get Response (and decode)
$response = $client->request('POST');
$jsonResponse = Zend_JSON::decode($response->getBody());

// Check if operation was successful
if($jsonResponse['success']==false)
    die('login Failed:'.$jsonResponse['error']['errorMsg']);

$session = $jsonResponse['result']['sessionName'];


// Query to select contacts
$query = "select * from contacts";

// Urlencode the query
$encodedQuery = urlencode($query);

//Create HTTP Client and set url and parameters
$client->setUri('https://example.com/webservice.PHP');
$client->setParameterGet(array(
    'operation' => 'query',
    'sessionName' => $session,
    'query' => $encodedQuery
));

// Get Response (and decode)
$response = $client->request('GET');
$jsonResponse = Zend_JSON::decode($response->getBody());

// Check if operation was successful
if($jsonResponse['success']==false)
    die('query Failed:'.$jsonResponse['errorMsg']);

// Return contacts
$retrievedobjects = $jsonResponse['result'];

解决方法:

不要对您的查询进行编码,只需这样做:

// Query to select contacts
$query = "select * from Contacts";

//Create HTTP Client and set url and parameters
$client->setUri('https://example.com/webservice.PHP');
$client->setParameterGet(array(
    'operation' => 'query',
    'sessionName' => $session,
    'query' => $query
));

我想vTiger Web服务的官方文档是错误的..

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...