
discuz和ucenter通信失败
按照网上的方法,一步一步检查,最终解决了问题,现在把可能的问题总结如下:
1、UC_APPID 与 UCenter 中的应用ID可能不一致:
以Discuz! X2.5为例,配置文件的目录为:./config/config_ucenter.php 找到如下图所示的位置:


2、应用的主 URL 地址即站点地址必须与 UCenter 后台的应用地址相同,站点的访问地址与UCenter 后台该应用的地址也必须一致:

3、配置文件中的通信密钥必须与 UCenter 后台的通信密钥保持一致,配置文件的通信密钥可以在./config/config_ucenter.php 中看到:


4、UCenter IP 地址要与服务器的 ip 地址相同,可以在配置文件中修改 IP 地址,如图


5、检查配置文件中的表前缀是否填写正确,位置在./config/config_ucenter.php 中:

6、fsockopen函数被禁用:
检查 php 环境,是否禁用了 fsockopen 函数,可以通过 php.ini 来查看该函数的情况,在这个文件中查找:
allow_url_fopen
改为
allow_url_fopen = On
7、应用域名301重定向的情况:
301重定向可以用fsockopen函数进行测试:用下面的代码
<?php $fp = fsockopen("[url=http://www.1.com]www.1.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.1.com\r\n]www.1.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 跳转规则有问题。