Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

Copy Format Clear

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<?php function aes_encode($key, $str) { $data = openssl_encrypt($str, 'AES-128-ECB', $key, OPENSSL_RAW_DATA); $data = strtolower(bin2hex($data)); return $data; } $server = 'http://gvsoa.com:20883'; // 请替换为实际的服务器 URL $postParams = array( 'grant_type' => 'password', 'client_id' => 'RNIHEHVSZAZZNHWJIVUIQCTSQMUGTRQS', 'client_secret' => aes_encode('891049691681066ac820978013714090', '891049691681066ac820978013714090'), 'username' => 'userName', 'password' => 'passWord' ); $ch = curl_init($server . "/oauth2/token"); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded')); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postParams)); $response = curl_exec($ch); if ($response === false) { $error = curl_error($ch); curl_close($ch); echo "Curl request failed: $error"; } else { $otoken = json_decode($response, true); if ($otoken === null) { echo "Failed to decode JSON response"; } else { $otoken = $otoken['access_token']?? null; if ($otoken === null) { echo "Access token not found in response"; } else { echo "Access Token: $otoken"; } } curl_close($ch); }
Copy Clear