wechat.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. # wechat基本配置
  3. # 基本的component token
  4. $config['token'] = array
  5. (
  6. 'method' => 'post',
  7. 'json' => true,
  8. 'url' => 'https://api.weixin.qq.com/cgi-bin/component/api_component_token?',
  9. 'param' => array
  10. (
  11. 'component_appid' => 'appid',
  12. 'component_appsecret' => 'secret',
  13. 'component_verify_ticket' => 'ticket',
  14. ),
  15. //针对一些返回的名称,做转换
  16. 'response' => array
  17. (
  18. 'component_access_token' => 'token',
  19. //'expires_in' => 'expires_in',
  20. ),
  21. );
  22. # oauth token
  23. $config['oauth'] = array
  24. (
  25. //第一步,请求code
  26. 'code' => array
  27. (
  28. 'method' => 'post',
  29. 'json' => true,
  30. 'url' => 'https://api.weixin.qq.com/cgi-bin/component/api_create_preauthcode?',
  31. 'param' => array
  32. (
  33. 'component_access_token' => 'token',
  34. 'component_appid' => 'appid',
  35. ),
  36. 'response' => array
  37. (
  38. 'pre_auth_code' => 'oauth.code',
  39. ),
  40. ),
  41. //第二步,拼装redirect,进行授权登录
  42. 'login' => array
  43. (
  44. 'method' => 'get',
  45. 'json' => false,
  46. 'url' => 'https://mp.weixin.qq.com/cgi-bin/componentloginpage?',
  47. 'param' => array
  48. (
  49. 'component_appid' => 'appid',
  50. 'pre_auth_code' => 'code',
  51. 'redirect_uri' => 'redirect',
  52. 'auth_type' => '3',
  53. ),
  54. ),
  55. //第三步,获取到token
  56. 'oauth' => array
  57. (
  58. 'method' => 'post',
  59. 'json' => true,
  60. 'url' => 'https://api.weixin.qq.com/cgi-bin/component/api_query_auth?',
  61. 'param' => array
  62. (
  63. 'component_access_token' => 'token',
  64. 'component_appid' => 'appid',
  65. 'authorization_code' => 'code',
  66. ),
  67. 'response' => array
  68. (
  69. 'authorization_info.authorizer_appid' => 'openid',
  70. 'authorization_info.authorizer_appid' => 'unionid',
  71. 'authorization_info.authorizer_access_token' => 'oauth.oauth',
  72. 'authorization_info.authorizer_refresh_token' => 'refresh',
  73. ),
  74. ),
  75. );
  76. return $config;