wechat.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. # wechat基本配置
  3. # 第一步 请求
  4. $config['auth'] = array
  5. (
  6. 'url' => 'https://open.weixin.qq.com/connect/oauth2/authorize',
  7. 'param' => array
  8. (
  9. 'appid' => '',
  10. 'redirect_uri' => '',
  11. # 重命名,如果key不是response_type的话
  12. //'response_type' => array('response_type', 'code'),
  13. 'response_type' => 'code',
  14. 'scope' => 'snsapi_userinfo',
  15. 'state' => '',
  16. //'contact' => '#wechat_redirect',
  17. )
  18. );
  19. # 第二步 获取token
  20. $config['token'] = array
  21. (
  22. 'url' => 'https://api.weixin.qq.com/sns/oauth2/access_token',
  23. 'param' => array
  24. (
  25. 'appid' => '',
  26. 'secret' => '',
  27. 'code' => '',
  28. 'grant_type' => 'authorization_code',
  29. ),
  30. 'response' => array
  31. (
  32. 'access_token' => '',
  33. 'expires_in' => '',
  34. 'refresh_token' => '',
  35. 'openid' => '',
  36. 'unionid' => '',
  37. 'scope' => '',
  38. 'errcode' => '',
  39. 'errmsg' => '',
  40. )
  41. );
  42. # 第三步 获取用户信息
  43. $config['user'] = array
  44. (
  45. 'url' => 'https://api.weixin.qq.com/sns/userinfo',
  46. 'param' => array
  47. (
  48. 'access_token' => 'access_token',
  49. 'openid' => 'openid',
  50. 'lang' => 'zh_CN',
  51. )
  52. );
  53. return $config;