The code is as follows
-
<? php -
error_reporting (E_ALL ^ E_NOTICE); -
function aveCard(){ -
$url = '' ; //Interface address -
$data = array ( -
'encode'=>'json' -
); -
$ch = curl_init(); -
curl_setopt( $ch , CURLOPT_SSL_VERIFYPEER, false); -
curl_setopt( $ch , CURLOPT_SSL_VERIFYHOST, 2); -
curl_setopt( $ch , CURLOPT_URL, $url ); -
curl_setopt( $ch , CURLOPT_CUSTOMREQUEST, 'POST'); -
curl_setopt( $ch , CURLOPT_RETURNTRANSFER, true); -
curl_setopt( $ch , CURLOPT_TIMEOUT, 6); -
$response = curl_exec( $ch ); -
if ( $error =curl_error( $ch )){ -
return 'Damn it, it failed unexpectedly. F5 refresh and try again...'; //Failure display -
} -
curl_close( $ch ); -
$array_data = json_decode( $response ,true); -
//$array_data is the array retrieved. The specific data depends on the format returned by json, then the specified data is retrieved, placed in the place to be displayed, and I put it in the following table -
echo '<table border= "2" style= "width: 50%;border-collapse: collapse;border-spacing: 0;" ><tr><th></th><th></th> -
<tr><td ></td><td></td><td></td><td></td><td></td></tr> -
<tr><td ></td><td></td><td></td><td></td><td></td></tr> -
<tr><td></td><td></td><td></td><td></td><td></td></tr> -
</tr></table>'; -
} -
echo aveCard(); -
?>