コード例 #1
0
ファイル: sys_platform.php プロジェクト: aspirin/wp-xintaoke
                fn(msg);
                --maxtime;
            } else {
                clearInterval(timer);
                fn("已失效!");
            }
        }, 1000);
    }
</script>
<?php 
$app_xt = xt_get_app_xt();
$app_taobao = xt_get_app_taobao();
$app_paipai = xt_get_app_paipai();
$app_yiqifa = xt_get_app_yiqifa();
$app_weibo = xt_get_app_weibo();
$app_qq = xt_get_app_qq();
$_loginurl = $_loginurl = xt_platform_authorize_url('[PLATFORM]', 'authoritySuccess', 'admin');
?>
<div id="dashboard-widgets-wrap">
    <?php 
if (IS_CLOUD) {
    if (strpos(home_url(), 'sinaapp.com') !== false) {
        ?>
            <div class="updated" style="color:red;font-weight: bold;font-size:15px;padding:10px 5px;">
                建议绑定自己的独立域名后,再到以下平台用独立域名申请APP,<a href="http://plugin.xintaonet.com/help/?id=126#X_Help-4" target="_blank">新浪SAE域名绑定</a>

            </div>
            <?php 
    } elseif (strpos(home_url(), 'duapp.com') !== false) {
        ?>
            <div class="updated" style="color:red;font-weight: bold;font-size:15px;padding:10px 5px;">
コード例 #2
0
ファイル: xt-login.php プロジェクト: aspirin/wp-xintaoke
function xt_platform_qq_token()
{
    $app = xt_get_app_qq();
    include_once XT_PLUGIN_DIR . '/xt-core/sdks/taobao/TopClient.php';
    //请求参数
    $postfields = array('grant_type' => 'authorization_code', 'client_id' => $app['appKey'], 'client_secret' => $app['appSecret'], 'code' => $_GET['code'], 'state' => $_GET['state'], 'redirect_uri' => xt_platform_qq_authorize_url());
    $client = new TopClient();
    try {
        $response = $client->curl(XT_QQ_TOKEN_URL, $postfields);
    } catch (Exception $e) {
        wp_die($e->getMessage());
    }
    if (strpos($response, "callback") !== false) {
        $lpos = strpos($response, "(");
        $rpos = strrpos($response, ")");
        $response = substr($response, $lpos + 1, $rpos - $lpos - 1);
        $msg = json_decode($response);
        if (isset($msg->error)) {
            wp_die($response);
        }
    }
    $token = array();
    parse_str($response, $token);
    $token['expires_in_date'] = date('Y-m-d H:i:s', current_time('timestamp') + $token['expires_in']);
    $access_token = $token['access_token'];
    $graph_url = "https://graph.qq.com/oauth2.0/me?access_token=" . $access_token;
    try {
        $response = $client->curl($graph_url);
    } catch (Exception $e) {
        wp_die($e->getMessage());
    }
    if (strpos($response, "callback") !== false) {
        $lpos = strpos($response, "(");
        $rpos = strrpos($response, ")");
        $response = substr($response, $lpos + 1, $rpos - $lpos - 1);
    }
    $response = json_decode($response, true);
    //openid
    if (isset($response['error'])) {
        wp_die($response['error_description']);
    }
    $openid = $response['openid'];
    $get_user_info = "https://graph.qq.com/user/get_user_info?" . "access_token=" . $access_token . "&oauth_consumer_key=" . $app["appKey"] . "&openid=" . $openid . "&format=json";
    try {
        $response = $client->curl($get_user_info);
    } catch (Exception $e) {
        wp_die($e->getMessage());
    }
    $user = json_decode($response, true);
    if ($user['ret'] > 0) {
        wp_die($user['msg']);
    }
    return array('id' => $openid, 'display_name' => $user['nickname'], 'token' => $token, 'sex' => $user['gender'] == 'm' ? '男' : '女', 'avatar' => $user['figureurl'], 'user' => $user);
}