Access to the API REST of CRM 2015 On-Premise in PHP
fr:Accéder à l'API REST de CRM 2015 On-Premise en PHP
en:Access to the API REST of CRM 2015 On-Premise in PHP
es:Con el resto de la API de CRM 2015 On-Premise en PHP
pt:Acesso para o resto da API de CRM 2015 no local em PHP
it:Accesso al resto di API di CRM 2015 On-Premise in PHP
nl:Toegang tot de API REST van CRM 2015 On-Premise in PHP
de:Zugang zum REST des CRM 2015 vor-Ort in PHP API
zh:访问 API 其余的 CRM 2015 上-前提在 PHP 中
ar:الوصول إلى بقية API لإدارة علاقات العملاء عام 2015 في الموقع في بي إتش بي
ja:API の残りの CRM 2015 オンプレミス php へのアクセス
pl:Dostęp do API REST z CRM 2015 wdrożonej w PHP
ru:Доступ к API REST из CRM к 2015 году на предприятии в PHP
ro:Acces la restul API de CRM 2015 On-Premise în PHP
he:גישה לשאר API של CRM 2015 מקומית ב- PHP
This article has been created by an automatic translation software. You can view the article source here.
fr:Accéder à l'API REST de CRM 2015 On-Premise en PHP
he:גישה לשאר API של CRM 2015 מקומית ב- PHP
ru:Доступ к API REST из CRM к 2015 году на предприятии в PHP
ja:API の残りの CRM 2015 オンプレミス php へのアクセス
ar:الوصول إلى بقية API لإدارة علاقات العملاء عام 2015 في الموقع في بي إتش بي
zh:访问 API 其余的 CRM 2015 上-前提在 PHP 中
ro:Acces la restul API de CRM 2015 On-Premise în PHP
pl:Dostęp do API REST z CRM 2015 wdrożonej w PHP
de:Zugang zum REST des CRM 2015 vor-Ort in PHP API
nl:Toegang tot de API REST van CRM 2015 On-Premise in PHP
it:Accesso al resto di API di CRM 2015 On-Premise in PHP
pt:Acesso para o resto da API de CRM 2015 no local em PHP
es:Con el resto de la API de CRM 2015 On-Premise en PHP
en:Access to the API REST of CRM 2015 On-Premise in PHP
Introduction
This article will provide you with access to theAPI REST de CRM 2015 On-Premise avec le langage PHP. Il faut que votre CRM to be connected with Active DIrectory and be in possession of your organization name on.span class='notranslate'>CRM.
Set its variables from work
// CRM Server
define('CRM_SERVER', 'NOM_DU_SERVEUR_CRM');
// CRM Organization
define('CRM_ORG_NAME', 'NOM_DE_LORGANISATION');
// CRM WSDL
define('CRM_WSDL', 'http://'.CRM_SERVER.'/'.CRM_ORG_NAME.'/XRMServices/2011/OrganizationData.svc');
// Active Directory
define('AD_DOMAIN_CONTROLER', "NOM_DU_SERVEUR_AD");
define("NTLM_LOGIN", "User");
define("NTLM_PASSWORD", "password");
Retrieve information
In this example, we'll retrieve information about an account.
// On crée l'URL de l'API REST
$url = CRM_WSDL."/AccountSet(guid'GUID_DU_COMPTE')";
// On initialise notre connexion à l'API
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERPWD, NTLM_LOGIN. ':' . NTLM_PASSWORD);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_FAILONERROR, 0);
curl_setopt($ch, CURLOPT_MAXREDIRS, 100);
// On crée nos headers
$headers = array("Content-Type:application/json; charset=utf-8", "Accept:application/json");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// On récupère le contenu
$account = curl_exec($ch);
Thanks to this, you can retrieve your data account.span class='notranslate'>JSON.
Update of information
On this example, we will update the email on an account.
// On crée notre objet à mettre à jour
$account = array();
$account['EMailAddress1'] = "adresse@domain.tld";
// On encode en JSON
$account = json_encode($account);
// On crée l'URL de l'API REST
$url = CRM_WSDL."/AccountSet(guid'GUID_DU_COMPTE')";
// On initialise notre connexion à l'API
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERPWD, NTLM_LOGIN. ':' . NTLM_PASSWORD);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_FAILONERROR, 0);
curl_setopt($ch, CURLOPT_MAXREDIRS, 100);
curl_setopt($ch, CURLOPT_POST, 1);
// On crée nos headers
$headers = array("X-HTTP-Method: MERGE", "Content-Type:application/json; charset=utf-8", "Accept:application/json");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// On l'envoi via CURL
curl_setopt($ch, CURLOPT_POSTFIELDS, $account);
// On récupère le contenu
$response = curl_exec($ch);
Return code of theAPI
When an error, theAPI Returns an array in JSON with the error code and error to help during the debug. During an update or a delete, if everything went correctly, theAPI Returns a variable equal to.span class='notranslate'>NULL.
Conclusion
Thanks to this article, you can now connect to theAPI de CRM 2015 for consultation or editing.
This article seem useful to you ?
Enable comment auto-refresher