You are being redirected

Solved
Complit
Getting noticed

You are being redirected

Probably a stupid question :-D.

 

I want to get all the clients on the network. My script is working but I get the sentence "You are being redirected" instead of an array with the data. If I click on the link behind "Redirected" I get all the data. But I need this info for my script. Any help would be great.

My code:
<?php

$request = new HttpRequest();
$request->setUrl('https://api.meraki.com/api/v0/devices/SERIALNUMBER/clients');
$request->setMethod(HTTP_METH_GET);

$request->setQueryData(array(
  'timespan' => '84000'
));

$request->setHeaders(array(
  'postman-token' => '7187e3f4-f792-c5f6-da1e-73e51253767d',
  'cache-control' => 'no-cache',
  'x-cisco-meraki-api-key' => 'api key'
));

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}

1 Accepted Solution
PhilipDAth
Kind of a big deal
Kind of a big deal

If you can't followed the redirect then you need to make an initial request to get the URL for your main request.

View solution in original post

2 Replies 2
PhilipDAth
Kind of a big deal
Kind of a big deal

If you can't followed the redirect then you need to make an initial request to get the URL for your main request.

Yes, the redirects will cause issues.

 

For example, I've included scripts in my JS code to handle it.

https://github.com/dexterlabora/meraki-splash-gp/blob/master/request-meraki.js

 

meraki-service (in development)

https://dexterlabora.github.io/meraki-service/

 

(sorry no PHP example)

 

 

Get notified when there are additional replies to this discussion.