Quantcast
Channel: THWACK: All Content - Orion SDK
Viewing all articles
Browse latest Browse all 2677

How to page json data.

$
0
0

I am trying to download some data from Solarwinds so I can see how we are progressing in moving items from whatsup. Using SQWL works great but I want to get the data programatically. This code works great except for one thing it only returns about 795 entries out of 2000. How do you get it to either return all data or to page through the data?

<?php

$data = array(

  'query' => "SELECT Caption, IPAddress, Community, Vendor,   OnCallGroup, workGroup

FROM Orion.Nodes

INNER JOIN Orion.NodesCustomProperties on Nodes.NodeID=NodesCustomProperties.NodeID"

  );

$url = "https://nms.nebraska.edu:17778/SolarWinds/InformationService/v3/Json/Query";

$jdata = json_encode($data);

$result = CallAPI($url, $jdata);

print $result;

 

function CallAPI($url, $data = false) {

   $ch = curl_init();

    // Authentication:

    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);

    curl_setopt($ch, CURLOPT_USERPWD, "uncsdom\\66581818:thisIsAPassword");

    curl_setopt($ch, CURLOPT_URL, $url);

    curl_setopt($ch, CURLOPT_COOKIEJAR,  "\\downloads\\whatsupsolar\\cookie.txt");

    curl_setopt($ch, CURLOPT_COOKIEFILE,  "\\downloads\\whatsupsolar\\cookie.txt");

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

    curl_setopt($ch, CURLOPT_POSTREDIR, 3);

    curl_setopt($ch, CURLOPT_VERBOSE, TRUE);

  curl_setopt($ch, CURLOPT_SSLVERSION, 3);

  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

  curl_setopt($ch, CURLOPT_VERBOSE, true);

  curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

  curl_setopt($ch, CURLOPT_HTTPHEADER, array(

                                        'Content-type: application/json',

                                        'Content-length: ' . strlen($data)

                                      ));

  $result = curl_exec($ch);

  $response = curl_getinfo($ch, CURLINFO_HTTP_CODE);

  $error = curl_error($ch);

  $info = curl_getinfo($ch);

  curl_close($ch);

    if ($result == false) {

  echo "Response: " . $response . "<br>";

  echo "Error: " . $error . "<br>";

  echo "Info: " . print_r($info);

  die();

  }

  return $result;

}

 

?>


Viewing all articles
Browse latest Browse all 2677

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>