• 模拟curl函数


    只要需要调用微信的网址,就需要模拟curl请求

     $tokenUrl="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$APPID}&secret={$SECRET}";

    private function api_notice_increment($url, $data){
    $ch = curl_init();
    // $header = "Accept-Charset: utf-8";
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    //curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $tmpInfo = curl_exec($ch);
    if (curl_errno($ch)) {
    return false;
    }else{
    return $tmpInfo;
    }
    }

  • 相关阅读:
    在ubuntu系统使用SSR
    Pandas库
    Numpy
    06-Python之标准库
    do{}while(0)
    inet_XX族函数
    大端小端
    c++ 强制类型转换
    auto类型推导
    const浅析
  • 原文地址:https://www.cnblogs.com/isuansuan/p/9822249.html
Copyright © 2020-2023  润新知