應(yīng)用與 UCenter 通信失敗是站長(zhǎng)們經(jīng)常遇見(jiàn)的問(wèn)題之一,通信失敗會(huì)造成的后果也很多,如上傳頭像時(shí)報(bào)錯(cuò)、新會(huì)員無(wú)法注冊(cè)、登錄密碼不正確等一系列的問(wèn)題,下面把 UCenter 通信失敗的解決方法總結(jié)并與大家分享。
UCenter 通信異常,一般有下面的一些癥狀:
1、頭像無(wú)法上傳出現(xiàn)了錯(cuò)誤提示:access denied for agent changed;
2、網(wǎng)站登錄提示密碼不正確或者沒(méi)響應(yīng);
3、會(huì)員無(wú)法注冊(cè);
4、各應(yīng)用不能同步登錄和退出;
5、UCenter后臺(tái)提示通信失??;
6、頭像顯示紅X;
7、登錄站點(diǎn)后臺(tái) => 點(diǎn)擊 UCenter 顯示 404 或者其它錯(cuò)誤。
還有很多各種各樣的情況,這里就不一一列舉了。
解決方法總結(jié)如下:
1、檢查站點(diǎn)配置文件中的 UC_APPID 與 UCenter 中的應(yīng)用ID是否一致以Discuz! X2.5為例,配置文件的目錄為:./config/config_ucenter.php 找到如下圖所示的位置
這里的值必須與 UCenter 后臺(tái)中應(yīng)用ID的值保持一致,如下圖所示。
2、應(yīng)用的主 URL 地址即站點(diǎn)地址必須與 UCenter 后臺(tái)的應(yīng)用地址相同比如站點(diǎn)的訪問(wèn)地址為:http: //www.discuz.net ,那么 UCenter 后臺(tái)該應(yīng)用的地址也必須是 http: //www.discuz.net。
3、配置文件中的通信密鑰必須與 UCenter 后臺(tái)的通信密鑰保持一致配置文件的通信密鑰可以在./config/config_ucenter.php 中看到。
這里的密鑰必須和 UCenter 后臺(tái)的保持一致。
4、UCenter IP 地址要與服務(wù)器的 ip 地址相同可以在配置文件中修改 IP 地址,如圖
同理,UCenter 后臺(tái)的應(yīng)用 IP 地址也要和配置文件中的一致。
應(yīng)用管理中,編輯站點(diǎn)應(yīng)用即可看到如下圖所示:
5、檢查配置文件中的表前綴是否填寫正確
位置在./config/config_ucenter.php 中
6、fsockopen函數(shù)被禁用檢查 php 環(huán)境,是否禁用了 fsockopen 函數(shù),可以通過(guò) php.ini 來(lái)查看該函數(shù)的情況,在這個(gè)文件中查找
將其改為
7、應(yīng)用域名301重定向的情況301重定向可以用fsockopen函數(shù)進(jìn)行測(cè)試:用下面的代碼
- <?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);
- }
- ?>
復(fù)制代碼將對(duì)應(yīng)的域名更改為 UCenter 應(yīng)用中的域名,然后訪問(wèn)此測(cè)試腳本,返回的內(nèi)容有 301 permanently 內(nèi)容,通信也會(huì)失敗。
您只要取消重定向即可,一般是 301 跳轉(zhuǎn)規(guī)則有問(wèn)題。
通過(guò)以上方法,便可以解決通信失敗的問(wèn)題。通常只要目錄權(quán)限正確,配置文件和后臺(tái)設(shè)置按照上面方法操作通信就不會(huì)出現(xiàn)問(wèn)題了。
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)
點(diǎn)擊舉報(bào)。