<?php
define('WXLOGIN',1);
$actionkey = isset($_GET['actionkey']) ? trim(htmlspecialchars($_GET['actionkey'])) : '';
$data = '';
@include("../../data/caches/wxlogin.php");
$appid    = $data['appid'];
$appsecret   = $data['appsecret'];

$data = '';
@include("../../data/caches/mobile.php");
$mobiledomain  = $data['mobiledomain'];

$callback = $data['mobiledomain'].'/include/wx_callback.php';
$callback = $callback.'?actionkey='.$actionkey;
$scope = 'snsapi_userinfo';
$state = 'mymps';

wx_login($appid, $scope, $state, $callback);

function wx_login($appid, $scope, $state, $callback)
{
    $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";
    header("Location:$login_url");
}
?>