<?php

/**
 * 360 accesstoken换取用户信息
 * @version
 *          1.0.0 Created at 2018-3-5. by --gwang
 * @author gwang (mail@wanggangzero.cn)
 * @copyright ? 2018-3-5, SJZ LoyalSoft Corporation & gwang. All rights reserved.
 */
include_once __DIR__ . '/../../../main.php';             # 导入game utils
include_once __DIR__ . '/../Mo/resp.php';                # 导入通用返回值结构
include_once __DIR__ . '/../Mo/payRequest.php';          # 导入通用订单请求结构
require_once __DIR__ . '/config_360.php';                # 配置文件

use loyalsoft\CLog;
use loyalsoft\JsonUtil;
use loyalsoft\HttpUtil;

HttpUtil::PostOnly();                                                           # 要求客户端必须以post方式提交数据
//参数: access_token
$str = HttpUtil::getQueryString();                                              # 提取参数字符串
//$str = \gzinflate($str);                                                      # 解压
$req = JsonUtil::decode($str);                                                  # 反序列化到对象
try {
    $params = array('access_token' => $req->access_token);
    $result = HttpUtil::makeRequest(QIHOO_API_USR, $params);
    if ($result['result']) {
        echo Resp::ok(JsonUtil::decode($result['msg']));
    } else {
        echo Resp::err($result['errno'], $msg);
    }
} catch (SDKException $e) {
    echo Resp::err($e->getCode(), $e->getMessage());
}
