Toegang tot de REST van de API van CRM 2015 On-Premise in PHP
Dit artikel is vertaald door middel van automatische vertalingssoftware. U kunt het artikel bron hier te bekijken.
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
Introductie
Dit artikel zal u voorzien van toegang tot deAPI REST de CRM 2015 On-Premise avec le langage PHP. Il faut que votre CRM worden aangesloten met Active DIrectory en in het bezit van de naam van uw organisatie op.span class='notranslate'>CRM.
Stel de variabelen van het werk
// 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");
Gegevens ophalen
In dit voorbeeld zullen we informatie over een account ophalen.
// 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);
Hierdoor kunt u uw account gegevens ophalen.span class='notranslate'>JSON.
Actuele informatie
Op dit voorbeeld zullen we de e-mail op een account bijwerken.
// 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);
Retourcode van deAPI
Wanneer er een fout, deAPI Deze eigenschap retourneert een matrix in JSON met de foutcode en de fout om te helpen tijdens de foutopsporing. Tijdens een update of een delete, als alles ging goed, deAPI Retourneert een variabele gelijk is aan.span class='notranslate'>NULL.
Conclusie
Dankzij dit artikel, kunt u nu verbinding maken met deAPI de CRM 2015 voor overleg of bewerken.
Dit artikel nuttig lijken voor u ?
Automatisch bijwerken van reacties inschakelen