Discuz!?

應用與 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 找到如下圖所示的位置

這裡的值必須與 UCenter 後臺中應用ID的值保持一致,如下圖所示。

Discuz! X2.5 與 UCenter 通訊失敗的解決方法

Discuz! X2.5 與 UCenter 通訊失敗的解決方法

2、應用的主 URL 地址即站點地址必須與 UCenter 後臺的應用地址相同

3、配置檔案中的通訊金鑰必須與 UCenter 後臺的通訊金鑰保持一致配置檔案的通訊金鑰可以在./config/config_ucenter.php 中看到。

這裡的金鑰必須和 UCenter 後臺的保持一致。

Discuz! X2.5 與 UCenter 通訊失敗的解決方法

Discuz! X2.5 與 UCenter 通訊失敗的解決方法

4、UCenter IP 地址要與伺服器的 ip 地址相同可以在配置檔案中修改 IP 地址,如圖

同理,UCenter 後臺的應用 IP 地址也要和配置檔案中的一致。應用管理中,編輯站點應用即可看到如下圖所示:

Discuz! X2.5 與 UCenter 通訊失敗的解決方法

Discuz! X2.5 與 UCenter 通訊失敗的解決方法

5、檢查配置檔案中的表字首是否填寫正確位置在./config/config_ucenter.php 中

Discuz! X2.5 與 UCenter 通訊失敗的解決方法

6、fsockopen函式被禁用檢查 php 環境,是否禁用了 fsockopen 函式,可以通過 php.ini 來檢視該函式的情況,在這個檔案中查詢

allow_url_fopen

將其改為

allow_url_fopen = On

7、應用域名301重定向的情況301重定向可以用fsockopen函式進行測試:用下面的程式碼

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$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=;;

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$out .= "Connection: Close\r\n\r\n";

fwrite($$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$fp, $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$out);

while (!feof($$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$fp)) {

echo fgets($$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$fp, 128);

}

fclose($$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$fp);

}

?>

將對應的域名更改為 UCenter 應用中的域名,然後訪問此測試指令碼,返回的內容有 301 permanently 內容,通訊也會失敗。您只要取消重定向即可,一般是 301 跳轉規則有問題。

問題, 密碼, 頭像, 後臺,
相關問題答案