API Samples: Difference between revisions

From MobileX for SageCRM
No edit summary
No edit summary
 
Line 1: Line 1:
PHP sample code on how to make a request to logon and get a SID
PHP sample code on how to make a request to logon and get a SID


   echo '<br /><br />starting...<br /><br />';
   echo 'starting...';
   $url = 'http://www.server.com/CRM/custompages/sagecrmws/KonneXGateway.aspx?SID=NO%20SID&action=logon';
   $url = 'http://www.server.com/CRM/custompages/sagecrmws/KonneXGateway.aspx?SID=NO%20SID&action=logon';
   $data = array('dataonly' => 'Y', 'username' => 'crmusername', 'password' => 'crmuserpassword', 'crmurl' => 'http://www.server.com/crm/');
   $data = array('dataonly' => 'Y', 'username' => 'crmusername', 'password' => 'crmuserpassword', 'crmurl' => 'http://www.server.com/crm/');
Line 15: Line 15:
   if ($result === FALSE) { /* Handle error */ }
   if ($result === FALSE) { /* Handle error */ }
   var_dump($result);
   var_dump($result);
   echo '<br /><br />Finished';
   echo 'Finished';

Latest revision as of 10:07, 18 November 2016

PHP sample code on how to make a request to logon and get a SID

 echo 'starting...';
 $url = 'http://www.server.com/CRM/custompages/sagecrmws/KonneXGateway.aspx?SID=NO%20SID&action=logon';
 $data = array('dataonly' => 'Y', 'username' => 'crmusername', 'password' => 'crmuserpassword', 'crmurl' => 'http://www.server.com/crm/');
 $options = array(
   'http' => array(
       'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
       'method'  => 'POST',
       'content' => http_build_query($data)
   )
 );
 $context  = stream_context_create($options);
 $result = file_get_contents($url, false, $context);
 if ($result === FALSE) { /* Handle error */ }
 var_dump($result);
 echo 'Finished';