cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
9605
Views
1
Helpful
2
Replies

You are being redirected

jonas@complit.be
Community Member

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

Accepted Solutions

Philip D'Ath
Meraki Community All-Star
Meraki Community All-Star
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

Philip D'Ath
Meraki Community All-Star
Meraki Community All-Star
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)