Get display API help

Hi.
Uses / get display to check the status of my screens. The problem is that it returns only the first 10 screens.

How do I do to get data from everyone? (About 30 screens)

/Nicklas

I find this pretty much works on any call it makes sense to use it on.

$api_data[‘start’] = ‘start=0’;

$api_data[‘length’] = ‘length=1000’;

start is the first record you want to return
length is how many in total you want starting from “start”

We use it in the following and it works well

$params = [
		'api_method' => 'GET',
		'api_path' => 'api/layout',
		'api_data' => [
			'form_params' => $api_data
		]
	];

Hope it helps.

While that suggestion does work, it does mean you are requesting up to 1000 records at once, which will put some strain on your CMS (probably not an issue as you don’t have 1000 displays).

The system is designed to use the Link header to describe the next page of results, and the X-Total-Count header to give the number of results.

Your application can use these headers to show a previous/next page button as appropriate.

This is my script. I´m only intressed in “name” and “logged in”

Can u please guide me how to change my code to show every screen?

Thanks :slight_smile:

<?php
$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => "http://xx.xx.xx.x/api/display",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_POSTFIELDS => "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"client_id\"\r\n\r\nlqDQiJiv8lEWi9TTddSgTGb8aIod0OLpLWP0ipnn\$
  CURLOPT_HTTPHEADER => array(
    "authorization: Bearer HOJF3nV3BXU29iucUWqSy250BhH2WFCEfsYjoGgf",
    "cache-control: no-cache",
    "content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
    "postman-token: 252342ff-5bcb-4aba-39fc-9814893329fa"
  ),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
  echo "cURL Error #:" . $err;
} else {
  $phpObj = json_decode($response);
  $arrlength = count($phpObj);
for ($x = 0; $x < $arrlength; $x++) {
  echo $phpObj[$x]->display;
  echo "  -  ";
  echo $phpObj[$x]->loggedIn;
  echo "<br>";
}
CURLOPT_URL => "http://xx.xx.xx.x/api/display?start=0&length=1000",
1 Like