i 收藏 开放接口 登录

演示地址:演示 - 使用 i 收藏 登录

i 收藏 开放接口:为第三方网站提供用户快捷登录

  • 无门槛,所有网站可接入
  • 不用授权,部署即用
  • 多平台支持,PC端、手机移动、微信内置浏览器

域名由 isc.net.cn 更换为 sc.uv.cc

i 收藏,个人网址收藏 

html 代码:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
    <title></title>

    <!-- jquery -->
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>

<script type="text/javascript">
function get_url_param(k) {
    var _list = location.search.substr(1).split('&')
    for (var _list2 of _list) {
        for (var item of _list2.split('?')) {
            var kv = item.split('=')
            if(kv[0] == k){
                return decodeURIComponent(kv[1])
            }
        }
    }
    return ''
}
</script>

<script type="text/javascript">
function win_open(url, w, h) {
    // 打开窗口网页
    var l = (screen.width - w) / 2,
    t = (screen.height - h) / 2
    window.open(url, "_blank", "width=" + w + ",height=" + h + ",toolbars=0,resizable=1,left=" + l + ",top=" + t)
}
</script>

</head>
<body>

<div id="login-isc" style="cursor: pointer;">使用 i 收藏登录</div>

</body>
<script type="text/javascript">
// 自动检测
(() => {
	if (get_url_param('oauth_token') != '') {
		window.opener.login_ok(get_url_param('oauth_token'))
		window.close()
	}
})()

// 登录成功后子页面的回调
function login_ok(oauth_token) {
    $.post("oauth.php", {
      	oauth_token: oauth_token,
    }, function(data){
        document.write(data)
    })
}
</script>

<script type="text/javascript">
// 前往登录
$("#login-isc").click(function(){
	win_open("http://isc.net.cn/login/?oauth_host="+ encodeURIComponent(location.host) +"&back_url=" + encodeURIComponent(location.href), 480, 490)
})
</script>

</html>

php代码:

<?php
$str = file_get_contents('http://isc.net.cn/login/token-oauth/?oauth_token=' . $_POST['oauth_token']);
$arr = json_decode($str, true);

echo "<pre>";
print_r($arr);

if ($arr['msg'] == 'ok') {
    @session_start();
    $_SESSION['isc-open_id'] = $arr['open_id'];
    $_SESSION['isc-user_name'] = $arr['user_name'];
}

提示:

对于同一用户、同一站点(第三方),返回的 open_id 是不变的,user_name 可能为空或改动。请使用 open_id 作为用户的唯一凭证,而不是 user_name。

更多咨询:kf@uv.cc

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

inksci

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值