• 微信新增图片信息


    /**
    * 上传永久图片的接口------------------------------------------------------------------------
    */
    public function actionNewupload()
    {
    $TOKEN=$this->actionToken();
    $file = "D:/upload/bb4.png";
    $data = array(
    'media'=> new CURLFile($file)
    );
    $url = 'https://api.weixin.qq.com/cgi-bin/material/add_material?access_token='.$TOKEN.'&type=image';
    $result = $this->curl_posts($url,$data);
    var_dump($result);
    }

    function curl_posts($url, $data, $header = array()){
    if(function_exists('curl_init')) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    if(is_array($header) && !empty($header)){
    $set_head = array();
    foreach ($header as $k=>$v){
    $set_head[] = "$k:$v";
    }
    curl_setopt($ch, CURLOPT_HTTPHEADER, $set_head);
    }
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 0);// 1s to timeout.
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    $response = curl_exec($ch);
    if(curl_errno($ch)){
    //error
    return curl_error($ch);
    }
    $reslut = curl_getinfo($ch);
    print_r($reslut);
    curl_close($ch);
    $info = array();
    if($response){
    $info = json_decode($response, true);
    }
    return $info;
    } else {
    throw new Exception('Do not support CURL function.');
    }
    }

  • 相关阅读:
    Docker容器管理神器
    查看MySQL连接状态
    使用 Docker 镜像安装 Radicale3
    Java文档注释的使用
    Hibernate依赖问题
    WPF HelixToolkit 3D
    二分法
    比较 React vue, 单向绑定 双向绑定 优缺点
    7 个杀手级的 JS 一行代码
    js中??和?.的意思
  • 原文地址:https://www.cnblogs.com/simadongyang/p/10537124.html
Copyright © 2020-2023  润新知