我有代碼連接到vtiger,現在我有問題,插入數據到vtiger模塊帳戶。選擇語句我沒有問題,它工作正常,但我不能插入數據。我想創建新的組織。插入vtiger表,php
function call($url, $params, $type = "GET")
{
$is_post = 0;
if($type == "POST") {
$is_post = 1;
$post_data = $params;
} else {
$url = $url . "?" . http_build_query($params);
}
$ch = curl_init($url);
if(!$ch) {
die("Cannot allocate a new PHP-CURL handle");
}
if($is_post) {
curl_setopt($ch, CURLOPT_POST, $is_post);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
$return = null;
if(curl_error($ch)) {
$return = false;
} else {
$return = json_decode($data, true);
}
curl_close($ch);
return $return;
}
$endpointUrl = 'http://localhost/vtigercrm/webservice.php';
$userName = 'username';
$password = 'pass';
$userAccessKey = 'acckey';
$sessionData = call($endpointUrl, array(
"operation" => "getchallenge",
"username" => $userName
));
$challengeToken = $sessionData['result']['token'];
$generatedKey = md5($challengeToken . $userAccessKey);
$dataDetails = call($endpointUrl, array(
"operation" => "login",
"username" => $userName,
"accessKey" => $generatedKey
), "POST");
$query = "INSERT INTO Accounts(accountname) VALUES ('some_name');";
$sessionid = $dataDetails['result']['sessionName'];
$getUserDetail = call($endpointUrl, array(
"operation" => "query",
"sessionName" => $sessionid,
'query' => $query
));
歡迎堆棧溢出!尋求調試幫助的問題(「**爲什麼不是這個代碼工作?」)必須包括期望的行爲,特定的問題或錯誤以及在問題本身**中重現**的最短代碼。沒有**明確問題陳述**的問題對其他讀者無用。請參閱:[如何創建最小,完整和可驗證示例](http://stackoverflow.com/help/mcve)。 – GrumpyCrouton