wxlogin.php 712 B

123456789101112131415161718192021
  1. <?php
  2. function wx_login($appid, $scope, $state, $callback)
  3. {
  4. $login_url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' . $appid . '&redirect_uri=' . urlencode($callback) . '&response_type=code' . '&scope=' . $scope . '&state=' . $state . '&connect_redirect=1#wechat_redirect';
  5. header('Location:' . $login_url);
  6. }
  7. define('WXLOGIN', 1);
  8. $actionkey = isset($_GET['actionkey']) ? trim(htmlspecialchars($_GET['actionkey'])) : '';
  9. $data = '';
  10. @include '../../data/caches/wxlogin.php';
  11. $appid = $data['appid'];
  12. $appsecret = $data['appsecret'];
  13. $callback = $data['callback'] . '?actionkey=' . $actionkey;
  14. $scope = 'snsapi_userinfo';
  15. $state = 'mymps';
  16. wx_login($appid, $scope, $state, $callback);
  17. ?>