应用与 UCenter 通信失败是站长们经常遇见的问题之一,通信失败会造成的后果也很多,如上传头像时报错、新会员无法注册、登录密码不正确等一系列的问题,下面把 UCenter 通信失败的解决方法总结并与大家分享。
UCenter 通信异常,一般有下面的一些症状:
1、头像无法上传出现了错误提示:access denied for agent changed;
2、网站登录提示密码不正确或者没响应;
3、会员无法注册;
4、各应用不能同步登录和退出;
5、UCenter后台提示通信失败;
6、头像显示红X;
7、登录站点后台 => 点击 UCenter 显示 404 或者其它错误。
还有很多各种各样的情况,这里就不一一列举了。
解决方法总结如下:
1、检查站点配置文件中的 UC_APPID 与 UCenter 中的应用ID是否一致
以Discuz! X2.5为例,配置文件的目录为:./config/config_ucenter.php 找到如下图所示的位置
[attach]45942[/attach]
这里的值必须与 UCenter 后台中应用ID的值保持一致,如下图所示。
[attach]45943[/attach]
2、应用的主 URL 地址即站点地址必须与 UCenter 后台的应用地址相同
比如站点的访问地址为:http: //www.discuz.net ,那么 UCenter 后台该应用的地址也必须是 http: //www.discuz.net。
[attach]45944[/attach]
3、配置文件中的通信密钥必须与 UCenter 后台的通信密钥保持一致
配置文件的通信密钥可以在./config/config_ucenter.php 中看到。
[attach]45945[/attach]
这里的密钥必须和 UCenter 后台的保持一致。
[attach]45946[/attach]
4、UCenter IP 地址要与服务器的 ip 地址相同
可以在配置文件中修改 IP 地址,如图
[attach]45947[/attach]
同理,UCenter 后台的应用 IP 地址也要和配置文件中的一致。
应用管理中,编辑站点应用即可看到如下图所示:
[attach]45948[/attach]
5、检查配置文件中的表前缀是否填写正确
位置在./config/config_ucenter.php 中
[attach]45949[/attach]
6、fsockopen函数被禁用
检查 php 环境,是否禁用了 fsockopen 函数,可以通过 php.ini 来查看该函数的情况,在这个文件中查找
复制代码
将其改为
复制代码
7、应用域名301重定向的情况
301重定向可以用fsockopen函数进行测试:用下面的代码- <?php
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$fp = fsockopen("[url=http://www.example.com]www.example.com[/url]", 80, $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$errno, $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$errstr, 30);
- if (!$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$fp) {
- echo "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$errstr ($$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$errno)
- \n";
- } else {
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$out = "GET / HTTP/1.1\r\n";
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$out .= "Host: [url=http://www.example.com\r\n]www.example.com\r\n[/url]";
- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$out .= "Connection: Close\r\n\r\n";
- fwrite($$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$fp, $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$out);
- while (!feof($$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$fp)) {
- echo fgets($$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$fp, 128);
- }
- fclose($$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$fp);
- }
- ?>
复制代码 将对应的域名更改为 UCenter 应用中的域名,然后访问此测试脚本,返回的内容有 301 permanently 内容,通信也会失败。
您只要取消重定向即可,一般是 301 跳转规则有问题。
通过以上方法,便可以解决通信失败的问题。通常只要目录权限正确,配置文件和后台设置按照上面方法操作通信就不会出现问题了。
|
|