User27
User27

Reputation: 545

How to integrate Dynamics CRM 2015 on-premise API using PHP and create leads

I am creating a web application in php, in that I need to integrate with Dynamics CRM 2015 on-premise API. Currently our CRM not using any authentication(not using ADFS). I have the following code which returns me some xml/array. But I am not sure if this is the expected output. It is returning only 'OrganizationData.svc'.

// The host name of the on-premises dynamics instance
$host = 'crm.mycompany.com';
$organization = 'MyCompany';
$crm_url = "http://$host/$organization/";

$username = 'username';
$password = 'password';

$url = $crm_url . 'XRMServices/2011/OrganizationData.svc/SystemUserSet';
$ch = curl_init();
 $headers = array(
      'Method: GET',
      'Connection: keep-alive',
      'User-Agent: PHP-SOAP-CURL',
      'Content-Type: application/json; charset=utf-8',
      'Accept: application/json',
      'Host: ' . $host);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$response = curl_exec($ch);

curl_close($ch);

$response=json_decode($response, true);

print_r($response);

Microsoft has given APIs to create: https://msdn.microsoft.com/en-us/library/mt770366.aspx , and retrive: https://msdn.microsoft.com/en-us/library/mt607871.aspx . but I am confused how do I use that?

Can someone please help me. I am new to API integration. Thanks a lot..

Upvotes: 0

Views: 1796

Answers (1)

Reuben Swartz
Reuben Swartz

Reputation: 206

So the apis that you have linked to are the new web api which is different then the old 2011 enpoint which you are using in your example. The web api (if I remember correctly) is in a preview form in 2015 and is incomplete. The documentation for the 2011 endpoint which can be found here. We could never quite get an external client to authenticate to CRM so if you can figure it out please let us know. How we implemented the crm integration with some of our non-microsoft systems is we used a small asp.net page that then used the crm client tooling to communicate with CRM on behalf of that application.

Upvotes: 1

Related Questions