"Query failed:Permission to perform the operation is denied for name" 在 vtiger webservice 查询中,我想通过它列出一个模块记录

"Query failed:Permission to perform the operation is denied for name" in vtiger webservice query through which I want to list one of module records

我在 vtiger 网络服务中遇到问题。任何人都可以帮我解决这个问题。我在 vtiger web 服务查询中收到此错误 "Query failed:Permission to perform the operation is denied for name",我想通过它列出模块记录之一。

我的密码是:

<?php
 require_once("../vtlib/Vtiger/Net/Client.php");
 require_once("../include/Zend/Json.php");

 class CRMwebrequests {
  var $endpointUrl;
  var $userName;
  var $userKey;
  var $token;

function __construct($url, $name, $key) {
    $this->endpointUrl=$url;
    $this->userName=$name;
    $this->userKey=$key;
    $this->token=0;
}

function getChallenge() {
    $httpc = new Vtiger_Net_Client($this->endpointUrl);
    $params["operation"]="getchallenge";
    $params["username"]=$this->userName;
    $response = $httpc->doGet($params);
    $httpc->disconnect();
    $jsonResponse = Zend_JSON::decode($response);
    if($jsonResponse["success"]==false)
    die("getChallenge failed:".$jsonResponse["error"]["message"]."<br>");

    $challengeToken = $jsonResponse["result"]["token"];

    return $challengeToken;
}

function Login() {
    $token = $this->getChallenge();
    $generatedKey = md5($token.$this->userKey);
    $httpc = new Vtiger_Net_Client($this->endpointUrl);
    //POST containing array
    $response = $httpc->doPost(
            array("operation"=>"login", "username"=>$this->userName,
            "accessKey"=>$generatedKey));
    $httpc->disconnect();
    $jsonResponse = Zend_JSON::decode($response);
    if($jsonResponse["success"]==false) {       
        die("Login failed:".$jsonResponse["error"]["message"]."<br>Token:".$token."<br>");
    }
    $sessionId = $jsonResponse["result"]["sessionName"];
    //save session id
    $this->token=$sessionId;
    //25765819bac6eb068
    return true;
}

function Query($query) {
    //handle "special" characters
    $queryParam = ($query);
    $params = array("sessionName"=>$this->token,"operation"=>"query", "query"=>$queryParam);

    $httpc = new Vtiger_Net_Client($this->endpointUrl);
    $response = $httpc->doGet($params);

    $jsonResponse = Zend_JSON::decode($response);
    echo "<pre>";
    print_r($jsonResponse);
    if($jsonResponse["success"]==false) {
        die("Query failed:".$jsonResponse["error"]["message"]);
    }
    //Array of retrieved objects
    $retrievedObjects = $jsonResponse["result"];
    return $retrievedObjects;
}


function delete($id){
    $params = array("sessionName"=>$sessionId, "operation"=>'delete', "id"=>$id);
    //delete operation request must be POST request.
    $httpc = new Vtiger_Net_Client($this->endpointUrl);
    $response = $httpc->doPost($params);
    $jsonResponse = Zend_JSON::decode($response);
    if($jsonResponse['success']==false){
        die('delete failed:'.$jsonResponse['error']['errorMsg']);
    }
    //Array of retrieved objects
    $retrievedObjects = $jsonResponse["result"];
    return $retrievedObjects;
}

function LogOut() {
    $params = array("operation"=>"logout","sessionName"=>$this->token);
    $httpc = new Vtiger_Net_Client($this->endpointUrl);
    $response = $httpc->doGet($params);
    $jsonResponse = Zend_JSON::decode($response);
    if($jsonResponse["success"]==false) {
        //handle the failure case.
        die("Logout failed:".$jsonResponse["error"]["message"]);
    }
    return true;
 }
}

  $CRMurl = 'http://localhost/vtigercrm';

  $APPkey = 'R6JNLCLkjCFTm44b';

  $crmobject = new CRMwebrequests($CRMurl."/webservice.php", "admin", $APPkey);

 if ($crmobject->Login()) {

 $wsquery = "SELECT * FROM vtiger_account";
 $Details = $crmobject->Query($wsquery);


echo "<b>Accounts</b><br>";
    echo "<table border='1'>";
        echo "<tr>";
            echo "<th>Account No</th>";
            echo "<th>Accoun Name</th>";
            echo "<th>Account Type</th>";
            echo "<th>Industry</th>";
            echo "<th>Ownership</th>";
        echo "</tr>";
    foreach ($Details as $value){
        echo "<tr>";
            echo "<td>".$value["account_no"]."</td>";
            echo "<td>".$value["accountname"]."</td>";
            echo "<td>".$value["account_type"]."</td>";
            echo "<td>".$value["industry"]."</td>";
            echo "<td>".$value["ownership"]."</td>";
        echo "</tr>";
    }
    echo "</table></br>";

 }
 else {
echo "Error!";
 }
?>

你不应该为你的 "SQL" 查询使用真实的数据库 table 名称,而应该只使用像这样的模块名称:

$query = "SELECT * FROM accounts;";
or
$query = "SELECT * FROM Contacts WHERE lastname='Valiant';";