PHP obtains the data method of interface URL through curl
- 2021-10-13 06:51:16
- OfStack
As shown below:
<?php
$weather = curl_init();
curl_setopt($weather,CURLOPT_URL,"https://api.pc2801.com/cqssc/".time());
curl_setopt($weather, CURLOPT_SSL_VERIFYPEER, false); // If the interface URL Yes https Adj. , We set it to not validate , If not https Interface of , You don't need to add this sentence
curl_setopt($weather,CURLOPT_RETURNTRANSFER,true);
$data = curl_exec($weather);
curl_close($weather);
$data=json_decode($data,true);// Will json Format to array format , Easy to use
?>