• php微信简单接口


    <?php
        $appid = "xxxxxxxxxx";
        $secret = "xxxxxxxxxxxxxxxxxxxxxxxxx";
        $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$appid."&secret=".$secret;
        function https_request($url){
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            $output = curl_exec($ch);
            curl_close($ch);
            $jsoninfo = json_decode($output, true);
            return $jsoninfo;
        }
        $code = https_request($url);
        function curlExec($url,$data=null){
            $postJosnData = json_encode($data);
            $ch = curl_init($url);
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $postJosnData);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
            $sourceInfo = json_decode(curl_exec($ch));
            echo "<pre>";
            print_r($sourceInfo);exit;
            curl_close($ch);
        }
        //获取所有素材列表
        $customer_url = 'https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token='.$code['access_token'];//地址
        $post_fields = array();
        //以下两项不需要修改
        $post_fields['type'] = 'news';
        $post_fields['offset'] = '0';
        $post_fields['count'] = '2';
     //   $buildingList = curlExec($customer_url,$post_fields);
    
        //获取单一素材详情
        $row_url = 'https://api.weixin.qq.com/cgi-bin/material/get_material?access_token='.$code['access_token'];//地址
        $row = array();
        //以下两项不需要修改
        $row['access_token'] = $code['access_token'];
        $row['media_id'] = 'njxothwKIB9tCEpdP4V-5yne0cSJ84QHo91Jr1NBc2A';
     //   $buildingList = curlExec($row_url,$row);
    
        //获取公众号粉丝分析
        unset($row);
        $data_url = 'https://api.weixin.qq.com/datacube/getusersummary?access_token='.$code['access_token'];//地址
        $row = array();
        //以下两项不需要修改
        $row['access_token'] = $code['access_token'];
        $row['begin_date'] = '2016-05-23';
        $row['end_date'] = '2016-05-24';
      //  $buildingList = curlExec($data_url,$row);
        //获取公众号粉丝分析
        unset($row);
        $data_url = 'https://api.weixin.qq.com/datacube/getarticlesummary?access_token='.$code['access_token'];//地址
        $row = array();
        //以下两项不需要修改
        $row['access_token'] = $code['access_token'];
        $row['begin_date'] = '2016-05-24';
        $row['end_date'] = '2016-05-24';
        $buildingList = curlExec($data_url,$row);
    ?>
    

      

  • 相关阅读:
    python 入门
    element 使用问题总结
    element dialog 弹窗 解决每次先加载上一次数据再加载本次数据问题
    JS 对变量进行全文替换方法
    react源码解析10.commit阶段
    react源码解析9.diff算法
    react源码解析8.render阶段
    react源码解析7.Fiber架构
    react源码解析6.legacy模式和concurrent模式
    react源码解析5.jsx&核心api
  • 原文地址:https://www.cnblogs.com/CHEUNGKAMING/p/5609506.html
Copyright © 2020-2023  润新知