<source id="wfbuo"><optgroup id="wfbuo"></optgroup></source>
<rt id="wfbuo"></rt><strong id="wfbuo"></strong>
<rt id="wfbuo"><optgroup id="wfbuo"></optgroup></rt>
<rt id="wfbuo"></rt>

  • <strong id="wfbuo"></strong>

    <menuitem id="wfbuo"></menuitem>
  • <strong id="wfbuo"></strong>
  • 當前位置 主頁 > 關于我們 > 站長日志 >

      curl_exec,PHP中的curl_exec獲取返回值中的json

      欄目:站長日志 時間:2021-03-26 17:09

           1.初始化一個curl對象
      $curl = curl_init();
           2.設置
      curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 
       
      $method);
      curl_setopt($curl, CURLOPT_URL, $url);
      curl_setopt($curl, CURLOPT_HTTPHEADER, 
       
      $headers);
      curl_setopt($curl, CURLOPT_FAILONERROR, false);//0,錯誤時不要失敗
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); //獲取的信息以文件流的形式返回,而不是直接輸出curl_setopt($curl, CURLOPT_HEADER, false); //返回頭部信息,設置為false,結果中就沒有頭部信息
      if (1 == strpos("$".$host, "https://"))
      {
          curl_setopt($curl, 
       
      CURLOPT_SSL_VERIFYPEER, false);
          curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
      }
      curl_setopt($curl, CURLOPT_POSTFIELDS, $bodys);
      $data = curl_exec($curl);
      return $data;
           返回值:
       
      {"code":0,"data":{"city":{"cityId":284609,"counname":"\u4e2d
       
      \u56fd","ianatimezone":"Asia\/Shanghai","name":"\u4e1c\u57ce
       
      \u533a","pname":"\u5317\u4eac\u5e02","secondaryname":"\u5317\u4eac
       
      \u5e02","timezone":"8"},"hourly":[{"condition":"\u6674","conditionId":"1","date":"2019
       
      -07-
       
      03","hour":"8","humidity":"54","iconDay":"0","iconNight":"30","pop":"0","pressure":"100
       
      2","qpf":"0.0","realFeel":"27","snow":"0","temp":"25","updatetime":"2019-07-03 
       
      08:04:20","uvi":"4","windDegrees":"45","windDir":"NNE","windSpeed":"4","windlevel":"1"}
       
      ,{"condition":"\u6674","conditionId":"1","date":"2019-07-
       
      03","hour":"9","humidity":"48","iconDay":"0","iconNight":"30","pop":"0","pressure":"100
       
      2","qpf":"0.0","realFeel":"29","snow":"0","temp":"28","updatetime":"2019-07-03 
       
      08:04:20","uvi":"6","windDegrees":"45","windDir":"NNE","windSpeed":"3","windlevel":"1"}
       
      ]},,"msg":"success","rc":{"c":0,"p":"success"}}
       
           原文鏈接:https://blog.csdn.net/hechenhongbo/article/details/94546262
      下一篇:沒有了
    推土機2019:ImageCombiner - Java服務端圖片合成工具,好用! 萊布尼茨:【從零開始擼一個App】Fragment和導航中的使用 等不到的口琴:億級流量架構之資源隔離思路與方法 TOP生物信息:一文學會常規轉錄組分析 Twittytop:我的2020之路 我愛睡蓮:keepalived-1.3.5+MHA部署mysql集群 程序員養成日記:mysql一張表到底能存多少數據? 等你歸去來:java線程池趣味事:這不是線程池 Linyiwei:C++算法代碼――Tuna Linux中執行shell腳本的4種方法總結 關于ios配置微信config出現驗簽失敗的問題解決 ASP.NET Core擴展庫之Http通用擴展庫的使用詳解 Java在Excel中添加水印的實現(單一水印、平鋪水印) 基于UDP協議實現聊天系統 R語言中ifelse、which、%in%的用法詳解 constant,Java中定義常量(Constant)的幾種方法 float,CSS Float(浮動),CSS Float(浮動)用法 fixed,JavaScript fixed() 方法,JavaScript fixed() 實例 sprintf,sprintf 函數用法詳細注解 html代碼 php網站,php網站搭建步驟,PHP環境搭建教程 調試js,JS調試,js調試工具 xml是什么.xml格式文件,xml怎么用 jsswitch語句,JavaScript Switch 語句,JavaScript Switch用法 html5 教程,什么是 HTML5,HTML5都有什么功能 css,通過JS修改CSS樣式 網站建設哪,什么是網站建設?網站建設的常見要素有哪些? html網站,前端html網站的發布過程 document.cookie,使用document對象操作cookie javascript 數組,JavaScript數組去掉重復數據總結
    欧美日韩免费无码