zoukankan      html  css  js  c++  java
  • 微信开发者-接口的相关配置

    1.获取access_token

    $access_token2 = 'https://api.weixin.qq.com/cgi-bin/token?appid=' . $appid . '&secret=' . $secret.'&lang=zh_CN&grant_type=client_credential';
             $res = file_get_contents($access_token2); //获取文件内容或获取网络请求的内容
              $result2 = json_decode($res,true); //接受一个 JSON 格式的字符串并且把它转换为 PHP 变量
              $access_token = $result2['access_token'];

    https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419317853&token=&lang=zh_CN

    正确的返回:


    "access_token":"ACCESS_TOKEN", 
    "expires_in":7200, 
    "refresh_token":"REFRESH_TOKEN", 
    "openid":"OPENID", 
    "scope":"SCOPE" 
    }

    2.获取用户基本信息

    $userinfo_url = 'https://api.weixin.qq.com/cgi-bin/user/info?access_token=' . $access_token . '&openid=' . $open_id . '&lang=zh_CN';
    $info = file_get_contents($userinfo_url);

    3.获取用户列表

    https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140840&token=&lang=zh_CN
     $userclient ='https://api.weixin.qq.com/cgi-bin/user/get?access_token='.$access_token;
    $userclientinfo = file_get_contents($userclient);
     $userinfo = json_decode($info, true);
    //下一批
    $userclientnext ='https://api.weixin.qq.com/cgi-bin/user/get?access_token='.$access_token.'&next_openid=o9rkxuKL8SgM8UTEwvtGfpsN_6P8';
    $userclientinfonext = file_get_contents($userclientnext);
    $userinfonext = json_decode($userclientinfonext, true);
    &next_openid=o9rkxuKL8SgM8UTEwvtGfpsN_6P8';上一批最后一个open_id

    在关注者与公众号产生消息交互后,公众号可获得关注者的OpenID(加密后的微信号,每个用户对每个公众号的OpenID是唯一的。对于不同公众号,同一用户的openid不同)。公众号可通过本接口来根据OpenID获取用户基本信息,包括昵称、头像、性别、所在城市、语言和关注时间。

    请注意,如果开发者有在多个公众号,或在公众号、移动应用之间统一用户帐号的需求,需要前往微信开放平台(open.weixin.qq.com)绑定公众号后,才可利用UnionID机制来满足上述需求。

    UnionID机制说明:

    开发者可通过OpenID来获取用户基本信息。特别需要注意的是,如果开发者拥有多个移动应用、网站应用和公众帐号,可通过获取用户基本信息中的unionid来区分用户的唯一性,因为只要是同一个微信开放平台帐号下的移动应用、网站应用和公众帐号,用户的unionid是唯一的。换句话说,同一用户,对同一个微信开放平台下的不同应用,unionid是相同的。 

    如果要交互,要利用微信开放平台unonid的唯一性

  • 相关阅读:
    CF280C Game on Tree 概率与期望
    bzoj 3420: Poi2013 Triumphal arch 树形dp+二分
    bzoj 2111: [ZJOI2010]Perm 排列计数 Lucas
    bzoj 3709: [PA2014]Bohater 贪心
    bzoj 1396/2865: 识别子串 后缀自动机+线段树
    【教程】如何搭建一个自己的网站
    C#单例设计模式
    C#双缓冲代码
    Hibernate的查询功能
    hibernate事务规范写法
  • 原文地址:https://www.cnblogs.com/lemonphp/p/5643545.html
Copyright © 2011-2022 走看看