<?php

header("Content-type: text/html; charset=utf-8");                               # 设置返回值编码头
header('Content-Encoding: deflate');
/**
 * Description of SidInfo.php
 *  九游sid换取玩家信息
 * @version
 *          1.0.0 Created at 2017-12-21. by --gwang
 * @author gwang (mail@wanggangzero.cn)
 * @copyright ? 2017-12-21, SJZ LoyalSoft Corporation & gwang. All rights reserved.
 */
// 导入game库
include_once __DIR__ . '/../../../main.php';
// 导入uc库
require_once __DIR__ . '/service/SDKServerService.php';
require_once __DIR__ . '/model/SDKException.php';
require_once __DIR__ . '/util/LoggerHelper.php';
// 导入自定义库
require_once __DIR__ . '/../Mo/payResp.php';

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

HttpUtil::PostOnly();                                                           # 要求客户端必须以post方式提交数据
$str = HttpUtil::getQueryString();                                              # 提取参数字符串
//$str = \gzinflate($str);                                                      # 解压
$req = JsonUtil::decode($str);                                                  # 反序列化到对象
try {
    $sidInfo = SDKServerService::verifySession($req->sid);                     # 验证sessionid并换取userInfo信息
    echo payResp::ok($sidInfo);
} catch (SDKException $e) {
    echo payResp::err($e->getCode(), $e->getMessage());
}

