Ejemplo n.º 1
0
<?php

/**
 * 获取第三方验证码
 * @author 潘洪学 panliu888@gmail.com
 * @create_date	2011-10
 */
include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '../init.php';
Passport::RequireLogin();
$api = Factory::CreateAPI($_GET['t'], $_GET['pid']);
ob_clean();
$api->showCode();
ob_end_flush();
Ejemplo n.º 2
0
include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '../init.php';
switch ($_GET['error']) {
    case 'login_denied':
        echo <<<HTML
<script>
window.close();
</script>
HTML;
        exit;
        break;
}
if (!Passport::IsLogin()) {
    redirect('../login.php?return_url=' . urlencode($_SERVER['REQUEST_URI']));
}
$pid = intval($_GET['pid']);
$api = Factory::CreateAPI($_GET['t'], $pid);
switch ($api->type) {
    case 'qzone':
        $code_key = 'oauth_vericode';
        break;
    case 'renren':
    case 'sina':
        $code_key = 'code';
        break;
    default:
        $code_key = 'oauth_verifier';
        break;
}
$token = $api->getAccessToken($_GET[$code_key], $_GET['oauth_token']);
if ($token['oauth_token']) {
    $api->openid = $token['openid'];
Ejemplo n.º 3
0
<?php

/**
 * 跳转到开放平台登录地址,RequestToken
 * @author 潘洪学 panliu888@gmail.com
 * @create_date	2011-10
 */
include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '../init.php';
Passport::RequireLogin();
$type = $_GET['t'];
$pid = intval($_GET['pid']);
$api = Factory::CreateAPI($type, $pid);
// 获取开放平台登录地址,跳转
switch ($api->type) {
    case 'kx001':
        $scope = 'send_feed create_records create_diary';
        break;
    case 'renren':
        $scope = 'admin_page publish_blog';
        break;
}
$cross = get_absolute_url('cross.php');
$auth_url = $api->GetAuthorizationUrl(get_absolute_url("bind.php?t={$type}&pid={$pid}&redir={$cross}", $api->callback), $scope);
if (start_with($auth_url, 'http')) {
    redirect($auth_url);
} else {
    echo $auth_url;
}