PHP code example of tangkoko / dynamics-sdk-php

1. Go to this page and download the library: Download tangkoko/dynamics-sdk-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tangkoko / dynamics-sdk-php example snippets


use Microsoft\Dynamics\Dynamics;
use Microsoft\Dynamics\Model;

class UsageExample
{
    $instanceUrl = 'https://contoso.crm.dynamics.com';
    $accessToken = 'xxx';

    $dynamics = new Dynamics();
    $dynamics->setInstanceUrl($instanceUrl)
             ->setAccessToken($accessToken);

    $leads = $dynamics->createRequest("GET", "/leads")
                  ->setReturnType(Model\Lead::class)
                  ->execute();

    $lead = $leads[0];

    echo "Hello, I am $lead->getFirstName() ";

    // OR GET a specific lead by ID

    $lead = $dynamics->createRequest("GET", "/leads(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)")
                  ->setReturnType(Model\Lead::class)
                  ->execute();

    echo "Hello, I am $lead->getFirstName() ";
}