I am trying to extract some data from Microsoft Dynamics CRM 2011 Online that is on a remote host; it works if I manually (from a browser) log into the system and execute mine from my server, which runs PHP on the Linux host, but, of course, I want to authenticate and run CRUD operations without my mediation :).
But he continues to show me "The object has moved here." pages for authentication. If I set CURLOPT_FOLLOWLOCATION => 1, it will display the crm login page.
If anyone can offer any clue to resolve the situation ... thanks!
<?php
$useragent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";
$urlValue = "/LeadSet?$select=Address1_City,FirstName,LastName";
$username = "domain\user";
$pass = "pass";
$handle = curl_init();
curl_setopt_array($handle,
array (
CURLOPT_USERAGENT => $useragent,
CURLOPT_USERPWD => $username . ':' . $pass,
CURLOPT_HTTPAUTH => CURLAUTH_ANY,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_URL => 'https://myhost.com/xrmservices/2011/OrganizationData.svc',
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $urlValue,
CURLOPT_RETURNTRANSFER => true,
)
);
$response = curl_exec($handle);
curl_close($handle);
header('Content-Type: text/plain;');
print_r($response);
source
share