Your browser (Internet Explorer 6) is out of date. It has known security flaws and may not display all features of this and other websites. Learn how to update your browser.
X

Open Source Web to Microsoft Dynamics CRM 2011 PHP Library using JSON

It is a tough one working with Microsoft Dynamics CRM 2011 with PHP, there is little or no documenations on this online. All the libraries we got are just not the right thing. The challenge ranges from authentication to defining the right data types (new data types are introduced, like money, option sets, two option set value and so on).

This got me and another developer (Nnadozie Omeonu) going sleepless for days as this task proves impossible and we can't just give the management "NO" for an answer. After so much of ado, reading Microsoft MSDN and so many unguided information online. We were able to resolve this and we feel the best way to help the open source community is to give it out as an Open Source Library under GPL.

We are able to come up with something simple and you can find it on GitHub here https://github.com/akinyeleolubodun/PHP-MS-Dynamics-CRM.

Below is a sample implementation:

Datatypes  - Boolean, DateTime, Decimal, Double, UniqueIdentifier, Integer, BigInt, String, EntityReference, OptionSetValue, Money, BooleanManagedProperty

Step 1: Include the library

    include("../../Crm.php");

Step 2: Build Ur Array in the following format

    $array = array
              (
                array(field name,value,datatype),
                array("LastName","Nnadozie","String"),
                array("Amount",78.099,"Decimal"),
                array("Age",78,"Integer"),
                array("Amount2",78.099,"Double"),
                .
                .
                .
                array("money",78.099,"Money"),


              );

Step 3: Create an Object Passing in 3 Argumments username,password,and link

    $test = new Crm("test","P@ssw0rd","http://testserver:80/Server/XRMServices/2011/OrganizationData.svc/pcl_ContactSet/");

Step 4: Build The JSON File

    $data = $test->buildJSON($array);

Step 5: Post Your Data

    $response = $test->PostData($data);

Retrieving Data

$crm = new Crm("test","P@ssw0rd","http://testserver:80/Server/XRMServices/2011/OrganizationData.svc/pcl_ContactSet/(guid'cda450bd-65f1-e311-85bb-001bcd0310a3')");
$data = $crm->buildJSON($array);
$crm->RetrieveData("127.0.0.1");

This is our humble contribution to the community. :-)

Regards.

 


comments powered by Disqus