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);
?>

  

转载于:https://www.cnblogs.com/CHEUNGKAMING/p/5609506.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值