Hi,
can anyone of you give an example of how I use the api in ajax, html or php can use? I am not an ajax benefited & the wiki that I do not understand so - hope to help
greeting
PHP Code:
<?php
$tc2_link = "xxx";
$tc2_port = "xxx";
$tc2_target = '/api';
$tc2_user = "admin";
$tc2_pass = "xxx";
$timeout = 30;
$posts = array ( 'op' => 'ListDJS',
'seq' => '' );
$method = "POST";
foreach( $posts AS $name => $value ){
$postValues .= urlencode( $name ) . "=" . urlencode( $value ) . '&';
}
$postValues = substr( $postValues, 0, -1 );
$lenght = strlen( $postValues );
$request = "$method $tc2_target HTTP/1.1\r\n";
// $request .= "User-Agent: XML Getter (Mozilla Compatible)\r\n";
$request .= "Authorization: Basic ".base64_encode("$tc2_user:$tc2_pass")."\r\n";
$request .= "Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\n";
$request .= "Content-Length: $lenght\r\n";
$request .= "\r\n";
$request .= $postValues;
$socket = fsockopen( $tc2_link, $tc2_port, $errno, $errstr, $timeout );
fputs( $socket, $request );
$ret = '';
// while ( !feof( $socket ) ) {
$ret = fgets( $socket, 4096 );
// }
fclose( $socket );
echo "Adresse: ".$tc2_link." - Port: ".$tc2_port." - ErrNo: ".$errno." - Fehler: ".$errstr." - TO: ".$timeout."<br><br>\r\n\r\n";
echo $request."<br><br>\r\n\r\n";
echo $ret;
?>