Example of accessing AMP APIs using Zend

Aruba Employee

This example uses the Zend Framework (framework.zend.com) to get data from ap_list.xml:

 

$baseUrl = "https://myampserver.domain.com";
$username = "myuser";
$password = "mypassword";

$client = new Zend_Http_Client();
$client->setCookieJar();
$client->setUri($baseUrl."/LOGIN");
$client->setParameterPost('credential_0',$username);
$client->setParameterPost('credential_1',$password);
// we are simply authenticating
$client->setParameterPost('destination',$baseUrl);
$response = $client->request('POST');

// Then we can go on and use other uri's for example getting an AP with
id of '123' in xml
// Just comment out the $arguments line if you want to grab all of them
$arguments = array('id' => 123);

$client->setUri($baseUrl."/ap_list.xml");

if(isset($arguments))
{
foreach($arguments as $arg => $value)
$client->setParameterGet($arg, $value);
}

$response = $client->request('GET');
$xml = new SimpleXMLElement($response->getBody());

Version history
Revision #:
1 of 1
Last update:
‎06-27-2014 12:07 PM
Updated by:
 
Labels (1)
Contributors
Search Airheads
cancel
Showing results for 
Search instead for 
Did you mean: