Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function RetrieveData($account, $dataset, $kind, $apiToken)
- {
- $port = "";
- if ($account === "localtest") {
- $port = ":8443";
- }
- $requestURI = "https://" . $account . ".evergage.com" . $port . "/api/dataset/" . $dataset . "/" . $kind . ".json?_at=" . $apiToken;
- debug_to_console("request URL: " . $requestURI);
- $session = curl_init();
- curl_setopt($session, CURLOPT_FAILONERROR, false);
- curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($session, CURLOPT_FOLLOWLOCATION, false);
- curl_setopt($session, CURLOPT_HEADER, true);
- curl_setopt($session, CURLOPT_SSL_VERIFYHOST, false);
- curl_setopt($session, CURLOPT_SSL_VERIFYPEER, false);
- $headers = array(
- 'Accept: application/json',
- 'Content-Type: application/json',
- );
- curl_setopt($session, CURLOPT_HTTPHEADER, $headers);
- curl_setopt ($session, CURLOPT_CUSTOMREQUEST, "GET");
- curl_setopt($session, CURLOPT_URL, $requestURI);
- // EVERYTHING RUNS FINE UP TO THIS POINT
- set_time_limit(0);
- $response = curl_exec($session);
- debug_to_console("success");
- echo 'Curl error: ' . curl_error($session);
- $info = curl_getinfo($session);
- $responseCode = $info["http_code"];
- if ($responseCode >= 300) {
- print("Error loading data: " . $responseCode . "<br/>");
- print($response);
- } else {
- $body = substr($response, $info['header_size']);
- $decoded_result = json_decode($body, true);
- }
- curl_close($session);
- return $decoded_result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement