Skip to content

Instantly share code, notes, and snippets.

@antonioortegajr
Last active December 21, 2015 18:07
Show Gist options
  • Save antonioortegajr/e5fc0c9905c4c0557f03 to your computer and use it in GitHub Desktop.
Save antonioortegajr/e5fc0c9905c4c0557f03 to your computer and use it in GitHub Desktop.
GET listcomponents IDX Broker API call
<?php
// access URL and request method
$url = 'https://api.idxbroker.com/clients/listcomponents';
$method = 'GET';
// headers (required and optional)
$headers = array(
'Content-Type: application/x-www-form-urlencoded', // required
'accesskey: abcdefghijklmnopqrstuvwx', // required - replace with your own
'outputtype: json' // optional - overrides the preferences in our API control page
);
// set up cURL
$handle = curl_init();
curl_setopt($handle, CURLOPT_URL, $url);
curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
// exec the cURL request and returned information. Store the returned HTTP code in $code for later reference
$response = curl_exec($handle);
$code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
if ($code >= 200 || $code < 300){
//json_decode commented out for this lesson. More on that in a later lesson.
//$response = json_decode($response,true);
}
else
{
$error = $code;
}
print_r($response);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment