我正在使用 vTiger Web 服务通过查询检索包含我的联系人的 VtigerObjects 数组。我正在按照此处给出的说明进行操作:
https://wiki.vtiger.com/index.php/Webservices_tutorials
到目前为止,我得到了一个可以用来登录的质询 token ,所以它可以工作..但是从我尝试通过查询获取数据的那一刻起,我收到以下错误:
“执行操作的权限被拒绝查询”
我是管理员,所以我应该拥有所有权限,对吗?这是我的代码,我希望有人可以帮助我?
$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 Services 的官方文档是错误的。
关于php - vTiger 网络服务 : Permission to perform the operation is denied for query,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29215019/