Ok, I'm plugging away with the API, teaching myself PHP as I go, but I'm
having a few problems. (I'm using Alex Lanstein's example code he
posted a few months ago)
I used this PHP script, and I get error=Invalid operation
If I switch the $post variable with the commented out one, I can get a
session ID, so the username password is good, and the webserver can
reach/use the API.
Am I not formatting the string to be passed to the API correctly? I've
even tried $post = "op=getuserinfo&qtype=all&qval="; which should work
as well.
<?
$cam_admin_username = "username";
$cam_admin_password = "password";
##EX: hostname.yourschool.edu
$cam_hostname = " hostname.yourschool.edu ";
$file="/admin/cisco_api.jsp?";
$login_by_function="&admin=" . $cam_admin_username . "&passwd=" .
$cam_admin_password;
#// $post = "op=adminlogin";
$post = "op=getuserinfo&qtype=mac&qval=001B77242E52";
$data = $file . $post . $login_by_function;
#// Build the header
$header = "POST $data HTTP/1.1\r\n";
$header .= "Host: $cam_hostname\r\n";
$header .= "Content-type: text/html\r\n";
#$header .= "Content-length: " . (strlen($data)). "\r\n";
$header .= "Connection: close\r\n\r\n";
$connection = pfsockopen("ssl://$cam_hostname", 443, $errno, $errstr);
if ($connection)
{
fwrite($connection, $header);
while (!feof($connection)) {$buffer .= fgets($connection,128); }
fclose($connection);
}
else echo "$errno --- $errstr";
// clean up the output. CAM displays output in 'hidden' html comments
$buffer = str_replace("<!--", "<br /><br />", $buffer);
$buffer = str_replace("-->", "", $buffer);
echo "<pre>";
print_R($buffer);
?> Michael King
Technology Systems & Networking
Bridgewater State College