I need to authenticate and perform CURD operations in MS Dynamics CRM using PHP API.
I have referred Reference1 Reference2 Reference3 Reference4
and using the below steps:
settings >
Administration >
system settings >
previews >
accept terms & conditions >
Web API Developer Preview >
Enable Dynamics CRM Web API Preview to yes
which is given in Reference4
link.
When I access,
https://<your organization name>.crm.dynamics.com/api/data/contacts
and
https://<your organization name>.crm.dynamics.com/api/data/accounts
I can get all my contacts and accounts.
But now I want to access it through php using api,
- How to send the request for contacts and accounts?
- How to create an application using AAD for trail version without providing credit card details?
I tried the below code:
$ZDURL= 'https://www.microsoft.com/en-sg/dynamics/';
curlWrap("GET",$ZDURL);
function curlWrap($action,$ZDURL)
{
$ch = curl_init();
/* $data = array('accountType' => 'MICROSOFT DYNAMICS',
'id' => '83261c03-3a21-4c64-b62c-00d6c2127c64',
'source'=>'PHI-cUrl-Example',
'service'=>'lh2'); */
//curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "username:password");
curl_setopt($ch, CURLOPT_URL, $ZDURL);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$output = curl_exec($ch);
if($output===false)
{
echo "curl error >> ".curl_error($ch);
exit;
}
else
{
echo "No Curl error occurs";
echo "<pre>";print_r($output);
}
exit;
curl_close($ch);
$decoded = json_decode($output);
return $decoded;
}
It shows as below:
Finally, got this Query Data using the Web API link, but no idea how to pass the request using php.
Need a help to retrieve CRM details by using api.