关注微信公众号,获取最新信息

我在上一边文章《QQ互联平台个人开发者认证》中像大家介绍了QQ互联的认证,获取APP ID 和 APP Key的方法,同时也给大家推荐了一款免费的第三方登录插件TeConnect,下面我就给大家讲讲这个插件的使用方法。

插件安装:

与正常的typecho插件安装方式一样。

解压插件到Plugins目录;
在后台启用插件,并配置插件参数(方法见:参数配置 – 配置示例);

将callback.php文件放置在网站根目录下面
在当前使用主题的适当位置添加TeConnect_Plugin::show()方法,代码:

`<?php TeConnect_Plugin::show(); ?>`

默认typecho主题代码安装示意图:

默认typecho主题代码安装示意图

handsome主题代码安装示意图:

handsome主题代码安装示意图

回调问题:

[tabs]
[tab name=”回调问题官方文档:” active=”true”]

回调问题官方文档:

1. 什么是回调地址?

用户点击QQ登录跳转到QQ登录页面,登录成功后,应该跳转回网站。回调地址即在这里用来指定跳转回网站的URL。回调地址注册的目的是为了保障第三方APPID帐户的安全,以免被其他恶意网站盗用。需注意:1. 需要填写到站点接收qq登录信息的接口 例如:http://网站首页域名/api/oauth/QQ/callback.php ;2. 具体跳转URL将在程序中指定路径以及请求参数进行构造。

2.什么样的回调地址才满足加强校验的条件?

QQ互联登录返回给开发商的code,会传到开发商指定的专门处理code的URL,而不是域名下任意的URL,举个例子 <br />1). 比如开发商处理QQ互联返回的Code的URL是 <br />https://account.example.com/connect/callback/qq <br />2). 但是开发商在互联官网注册的回调地址是:example.com,因此属于不符合要求的回调地址。<br />3). 开发商需要到QQ互联官网上,把回调地址修改为把https://account.example.com/connect/callback/qq, 并去掉example.com。<br />4). 如果有多个回调地址的需求,可以多个回调,使用”;”隔开,如”https://account.example.com/connect/callback/qq;https://account.example.com/connect/qc”

[/tab]
[tab name=”回调地址设置:”]

回调地址错误,会返回错误码:100010。 回调地址错误的原因如下: (1)没有传入域名; (2)传入的域名与申请接入时填写的回调地址域名冲突。 例如:申请时填写的回调地址是:http://example.com/qqlogin,传入的是http://example.com则会返回错误码,需保证填写的回调地址和请求的一致

您可以复制对应的 配置示例,把 127.0.0.1改成您的域名,填写到第三方开发平台的网站回调域设置中,即可完成配置!

以本博客 www.iyuu.cn,设置腾讯QQ登录,为例:<br />复制:https://127.0.0.1/oauth_callback?type=qq<br />127.0.0.1改成 www.iyuu.cn,改好后:<br />https://www.iyuu.cn/oauth_callback?type=qq`
推荐同时设置2个提高兼容性:
https://127.0.0.1/oauth_callback?type=qq;https://127.0.0.1/index.php/oauth_callback?type=qq`

[/tab]

[tab name=”仍然错误码:100010:”]

在QQ互联中,我是按照原博提供的方法填入的回调域:

http://www.cyrilstudio.top/oauth_callback?type=qq;http://www.cyrilstudio.top/index.php/oauth_callback?type=qq

我多次测试后还是会出现100010错误代码,有时有,有时没有,后来结合QQ互联的官方文档,我将回调域地址重新修改了下,解决了这个问题:

http://www.cyrilstudio.top/index.php/oauth_callbacktype=qq&response_type=code&scope=get_user_info,

http://www.cyrilstudio.top/index.php/oauth_callback?type=qq&response_type=code&scope=get_user_info

[/tab]
[/tabs]

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

评论(2)

  • zbdrariI 普通 2021年 7月 12日 下午9:58

    1 ::aru:despise:: ::aru:knife:: ::aru:pouting:: ::aru:shutup:: ::aru:unhappy:: ::aru:discovertruth:: ::aru:shit:: ::aru:distressed:: ::aru:shy:: ::aru:speechless:: ::aru:confuse:: ::aru:frown:: ::aru:proud:: ::aru:cheer:: ::aru:meditation:: ::aru:diving:: ::aru:cryingface:: ::aru:lurking:: ::aru:thumb:: ::aru:smile:: ::aru:clap:: ::aru:envious:: ::aru:surrender:: ::aru:bigeye:: ::aru:nose:: ::aru:sweat:: ::aru:flower:: ::aru:crying:: ::aru:spit:: ::aru:surprised:: ::aru:blood:: ::aru:blood2:: ::aru:shy2:: ::aru:angry:: ::aru:nomatter:: ::aru:dead:: ::aru:insidious:: ::aru:tongue:: ::twemoji:smile:: ::twemoji:tongue:: ::twemoji:tilted:: ::twemoji:tiaomei:: ::twemoji:shy:: ::twemoji:sweat:: ::twemoji:proud:: ::twemoji:uncomfort:: ::twemoji:smilecry:: ::twemoji:love:: ::twemoji:notalk:: ::twemoji:happy:: ::twemoji:frightened:: ::twemoji:dtongue:: ::twemoji:cry:: ::twemoji:cool:: ::twemoji:bigsmile:: ::twemoji:ok:: ::twemoji:kiss:: ::twemoji:angry:: ::twemoji:family:: ::twemoji:congratulate:: ::twemoji:gift:: ::twemoji:prayer:: ::twemoji:star:: ::aru:despise:: ::aru:knife:: ::aru:pouting:: ::twemoji:smile:: ::twemoji:tongue:: ::twemoji:tilted:: ::twemoji:tiaomei:: ::twemoji:shy:: ::twemoji:sweat:: ::twemoji:proud:: ::twemoji:uncomfort:: ::twemoji:smilecry:: ::twemoji:love:: ::twemoji:notalk:: ::twemoji:happy:: ::twemoji:frightened::

  • zbdrariI 普通 2021年 7月 12日 下午9:58

    1 ::aru:despise:: ::aru:knife:: ::aru:pouting:: ::aru:shutup:: ::aru:unhappy:: ::aru:discovertruth:: ::aru:shit:: ::aru:distressed:: ::aru:shy:: ::aru:speechless:: ::aru:confuse:: ::aru:frown:: ::aru:proud:: ::aru:cheer:: ::aru:meditation:: ::aru:diving:: ::aru:cryingface:: ::aru:lurking:: ::aru:thumb:: ::aru:smile:: ::aru:clap:: ::aru:envious:: ::aru:surrender:: ::aru:bigeye:: ::aru:nose:: ::aru:sweat:: ::aru:flower:: ::aru:crying:: ::aru:spit:: ::aru:surprised:: ::aru:blood:: ::aru:blood2:: ::aru:shy2:: ::aru:angry:: ::aru:nomatter:: ::aru:dead:: ::aru:insidious:: ::aru:tongue:: ::twemoji:smile:: ::twemoji:tongue:: ::twemoji:tilted:: ::twemoji:tiaomei:: ::twemoji:shy:: ::twemoji:sweat:: ::twemoji:proud:: ::twemoji:uncomfort:: ::twemoji:smilecry:: ::twemoji:love:: ::twemoji:notalk:: ::twemoji:happy:: ::twemoji:frightened:: ::twemoji:dtongue:: ::twemoji:cry:: ::twemoji:cool:: ::twemoji:bigsmile:: ::twemoji:ok:: ::twemoji:kiss:: ::twemoji:angry:: ::twemoji:family:: ::twemoji:congratulate:: ::twemoji:gift:: ::twemoji:prayer:: ::twemoji:star:: ::aru:despise:: ::aru:knife:: ::aru:pouting:: ::twemoji:smile:: ::twemoji:tongue:: ::twemoji:tilted:: ::twemoji:tiaomei:: ::twemoji:shy:: ::twemoji:sweat:: ::twemoji:proud:: ::twemoji:uncomfort:: ::twemoji:smilecry:: ::twemoji:love:: ::twemoji:notalk:: ::twemoji:happy:: ::twemoji:frightened::