Last active
December 21, 2015 18:07
-
-
Save antonioortegajr/e5fc0c9905c4c0557f03 to your computer and use it in GitHub Desktop.
GET listcomponents IDX Broker API call
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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