Hello,
I am developing a web portal which all data stored in suitecrm, I need to retrieve some records from a module which I was created using module builder.
I am tried the following way , It gives me a error which is "Access Denied ", but It works when I gives the module name as default such as âNotesâ, âAccountsâ, etcâŚ
Please correct me anything wrong, or give me a suggestion how to achieve this tasksâŚ
private function get_session_id()
{
$login_parameters = array(
âuser_authâ => array(
âuser_nameâ => $this->username,
âpasswordâ => md5($this->password),
âversionâ => â1â),
âapplication_nameâ => âRestTestâ,
âname_value_listâ => array(),);
$login_result = $this->call(âloginâ, $login_parameters, $this->url);
$session_id = $login_result->id;
return $session_id;
}
public function get_tariffs()
{
$res=array();
$session_id=$this->get_session_id();
$get_entry_list_parameters = array(
âsessionâ => $session_id,
âmodule_nameâ => âTCB_Service_tariffsâ,
âqueryâ => ââ,
âorder_byâ => ââ,
âoffsetâ => â0â,
âselect_fieldsâ => array(
âidâ,
ânameâ)
);
$res = $this->call(âget_entry_listâ, $get_entry_list_parameters, $this->url);
return $res;
}
public function call($method, $parameters, $url)
{
ob_start();
$curl_request = curl_init();
curl_setopt($curl_request, CURLOPT_URL, $url);
curl_setopt($curl_request, CURLOPT_POST, 1);
curl_setopt($curl_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
curl_setopt($curl_request, CURLOPT_HEADER, 1);
curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_request, CURLOPT_FOLLOWLOCATION, 0);
$jsonEncodedData = json_encode($parameters);
$post = array(
âmethodâ => $method,
âinput_typeâ => âJSONâ,
âresponse_typeâ => âJSONâ,
ârest_dataâ => $jsonEncodedData
);
curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post);
$result = curl_exec($curl_request);
curl_close($curl_request);
$result = explode("\r\n\r\n", $result, 2);
$response = json_decode($result[1]);
ob_end_flush();
return $response;
}
Thanks.
Sivakumar Johnson.