logo

Web api : Manage users via API ( Method GET ,JSON ,AES-128-CBC)

API ip port http://www.example.com:4300/wapi/
API and crypto json line http://www.example.com:4300/wapi/8c621d990a059cd.....

ADD json $ptext ='{"command":"add","user":"alex","pass":"1234","notes":"test","maxcon":"10","enddate":"2018-09-28","categories":"2,3,4,5","ip":"","reseller":""}';
EDIT json $ptext ='{"command":"edit","user":"alex","pass":"1234","notes":"test","maxcon":"10","enddate":"2019-09-28","categories":"2,3,4,5","ip":"","reseller":""}';
DEL json $ptext ='{"command":"del","user":"alex"}';

Key from Nice restreamer $key = "o5YHCJYmP7AR2hEz"; $iv = "MH2mEr9N4XY3j6cr";

Response {"info":"add_ok"} * {"info":"add_err"} * {"info":"edit_ok"} * {"info":"edit_err"} * {"info":"del_ok"} * {"info":"del_err"} * {"info":"command_err"} * {"info":"key_err"} * {"info":"user_exists"}

<?php 
$ptext ='{"command":"add","user":"alex","pass":"1234","notes":"test","maxcon":"10","enddate":"2018-09-28","categories":"2,3,4,5","ip":"","reseller":""}';
//$ptext ='{"command":"edit","user":"alex","pass":"1234","notes":"test","maxcon":"10","enddate":"2019-09-28","categories":"2,3,4,5","ip":"","reseller":""}';
//$ptext ='{"command":"del","user":"alex"}';
$key = "o5YHCJYmP7AR2hEz";
$iv = "MH2mEr9N4XY3j6cr";
$ciphertext_raw = openssl_encrypt($ptext, "AES-128-CBC", $key, $options=OPENSSL_RAW_DATA, $iv);
$encoded = 'http://www.example.com:4300/wapi/' . bin2hex($ciphertext_raw);

$curl = curl_init($encoded); 

curl_setopt($curl, CURLOPT_FAILONERROR, true); 
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); 
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);   
$result = curl_exec($curl); 
$text = json_decode($result, true);

foreach($text as $keyi=>$value) {
    $message = $keyi . ":" . $value . "\n";
    echo $message;
}
?>