PHP通过curl获取接口URL的数据方法

2026-01-12 06:27:15 作者:用户投稿

如下所示:

<?php

 $weather = curl_init(); 
      curl_setopt($weather,CURLOPT_URL,"https://api.pc2801.com/cqssc/".time()); 
      curl_setopt($weather, CURLOPT_SSL_VERIFYPEER, false); //如果接口URL是https的,我们将其设为不验证,如果不是https的接口,这句可以不用加
      curl_setopt($weather,CURLOPT_RETURNTRANSFER,true);
      $data = curl_exec($weather); 
      curl_close($weather);     
      $data=json_decode($data,true);//将json格式转化为数组格式,方便使用

?>

以上这篇PHP通过curl获取接口URL的数据方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

猜你喜欢

联络方式:

400 9058 355

邮箱:8955556@qq.com

Q Q:8955556

微信二维码
在线咨询 拨打电话

电话

400 9058 355

微信二维码

微信二维码