PHP & Microsoft Dynamics CRM 2013 online
We’ve been using Microsoft Dynamics 2013 at work for a little while now. One thing that’s been on my to-do list since the beginning has been automating the creation of CRM accounts when our internal hosting system had a new account added.
On and off over the past couple of months, I’ve been trying various pieces of sample code dotted here and there and have not managed to get anything working. Until now that is.
The sample code came from a surprising source, Microsoft themselves! 🙂 Hidden away in the Dynamics CRM 2011 SDK is some PHP code. The code as-is is broken and won’t login to a Dynamics 2013 instance that uses Office 365 live-id’s for authentication. However, with a little tweaking it’s possible to get it all working!
Grab?the tweaked code from here
Edit Main.php and update the Username, Password and organizationServiceURL variables. When you execute Main.php it should:
- Create a new account
- Update the account with a new name
- If enabled, delete the account
[[email protected] crm]$ php Main.php Array (  => Array ( [name] => Newer Corporation [accountId] => b0d711b3-e629-e411-b376-d89d67631e7c ) ) Array (  => Array ( [name] => Updated Newer [accountId] => b0d711b3-e629-e411-b376-d89d67631e7c ) )
Update 20th Nov 2014: Due to changes of configuration on Microsoft’s servers, you’ll need to update LiveIDManager.php. Comment out the following line:
curl_setopt($cURLHandle, CURLOPT_SSLVERSION , 3);
Rather than specifying SSLv3, we want to allow curl to auto-negotiate the best SSL/TLS version available. Thanks to Django Radonich-Camp for spotting that.
2 thoughts on “PHP & Microsoft Dynamics CRM 2013 online”
Thanks for sharing your code, I found it useful for an application I am working on. I have managed to get keyIdentifier, securityToken0 and securityToken1 using your code. Now I am struggling to get an web api request working with these. Could you please share working code or point me in right direction to make that work.
Help much appreciated.
I’m afraid I no longer use Dynamics CRM and I don’t have a copy of my last working PHP code to refer you to either, sorry 🙁