Browse Category

Meraki API

Post about Meraki API

Meraki API – Change SSID with PHP

Hi,

Here is a example on how to change the SSID with Meraki API and PHP.

<?php
    //API KEY
    $apikey = 'API KEY HERE';
    //THE NUMBER OF THE SSID YOU WANT TO CHANGE, the first have the nnumber 0, so the range is 0-14
    $ssid_number = 'SSID NUMBER';
    //NETWORK NUMBER, example L_9837438944354469994
    $network = 'NETWORK NUMBER';
    //ENTER NEW SSID NAME  HERE
    $ssid = 'NEW SSID NAME';

    $url = "https://dashboard.meraki.com/api/v0//networks/".$network."/ssids/".$ssid_number."";

    $headr = array();
    $headr[] = 'Content-Type: application/json';
    $headr[] = 'X-Cisco-Meraki-API-Key:  '.$apikey;    
    
  $curl = curl_init($url);  
        
        $data = array("name" => $ssid);

$json = json_encode($data);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER,$headr);
curl_setopt($curl, CURLOPT_POSTFIELDS, $json);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);

// Make the REST call, returning the result
$response = curl_exec($curl);
if (!$response) {
    die("Connection Failure.n");
}
?>

Meraki API – With PHP for beginners

Here is a simple php page to list all you network inside your organization.

You just need to put in your org number and API Key.

<?php
   
    $apikey = 'INSERT API KEY HERE';
    $org = 'INSERT ORG NUMBER HERE';


    
    $url = "https://dashboard.meraki.com/api/v0/organizations/".$org."/networks";

    $headr = array();
    $headr[] = 'Content-Type: application/json';
    $headr[] = 'X-Cisco-Meraki-API-Key:  '.$apikey;

    //cURL starts
    $crl = curl_init();
    curl_setopt($crl, CURLOPT_URL, $url);
    curl_setopt($crl, CURLOPT_HTTPHEADER,$headr);
    curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($crl, CURLOPT_HTTPGET,true);
    curl_setopt($crl, CURLOPT_FOLLOWLOCATION, true);
    $reply = curl_exec($crl);

    //error handling for cURL
    if ($reply === false) {
       // throw new Exception('Curl error: ' . curl_error($crl));
       print_r('Curl error: ' . curl_error($crl));
    }
    curl_close($crl);
    //cURL ends
    //
    //decoding the json data



    $data =  json_decode($reply);

    ?>
<h1>Network overview:</h1>
<table width='600px' border='1'>
	<tbody>
		<tr>
			<th>Name</th>
                        <th>Type</th>

		</tr>
			<?php	
			foreach ($data as $value) {
				echo '<tr>';
				echo '<td>' . utf8_decode($value->name) . '</td>';
				echo '<td>' . $value->type . '</td>';
				echo '</tr>';
			}
			?>
	</tbody>
</table>

Meraki API – Where to find your organization number?

First log into you dashboard, and when logged in open this url.

https://dashboard.meraki.com/api/v0/organizations

then you will get the list over organizations your account have access to.

The output will look like this:

[{"id":351587,"name":"TEST Organization"}]