自定义身份验证反序列化失败:解析值时遇到意外字符

Custom authentication deserialization failed: Unexpected character encountered while parsing value

我在创建自定义身份验证时遇到问题!我正在使用 000WebHost 的免费主机在 Unity 上测试 Photon 的多人游戏,但在 Unity 调试中出现以下错误:

OperationResponse 230: ReturnCode: 32755 (Custom authentication deserialization failed: Unexpected character encountered while parsing value: U. Path '', line 0, position 0.).

Parameters: {} Server: NameServer Address: ns.exitgames.com:5058

UnityEngine.Debug:LogError(Object)

Photon.Realtime.LoadBalancingClient:DebugReturn(DebugLevel, String) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:1835)

Photon.Realtime.LoadBalancingClient:OnOperationResponse(OperationResponse) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:1909)

ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(StreamBuffer) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PeerBase.cs:616)

ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/EnetPeer.cs:545)

ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PhotonPeer.cs:1473)

Photon.Pun.PhotonHandler:FixedUpdate() (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:130)

我的Unity认证码:

using Photon.Pun;
using Photon;

public class Login : MonoBehaviour {

public InputField User_Input;
public InputField Pass_Input;
public Text Error_Text;

public string username;
public string password;

public void UserName(){
    username = User_Input.text.ToString ();
}
public void UserPass(){
    password = Pass_Input.text.ToString ();
}
public void SubmitLogin(){
    PhotonNetwork.AuthValues = new AuthenticationValues ();
    PhotonNetwork.AuthValues.AuthType = CustomAuthenticationType.Custom;
    PhotonNetwork.AuthValues.AddAuthParameter ("username", username);
    PhotonNetwork.AuthValues.AddAuthParameter ("password", password);
    PhotonNetwork.ConnectUsingSettings();
}
void OnJoinedLooby(){
    Debug.Log ("We did it");
}
void OnGUI(){
    GUILayout.Label (PhotonNetwork.connectionStateDetailed.ToString ());
}
}

我的服务器端代码:

<?php
include "db.php";

$username = $_GET['username'];
$password = $_GET['password'];

$check = mysqli_query($conn , "SELECT * FROM accounts WHERE `username`='".$username."'");
$numrows = mysqli_num_rows($check);
if ($numrows == 0){
    die ("Username does not exist.");
}else{
    $password = md5($password);
        while($row = mysqli_fetch_assoc($check)){
            if ($password == $row['password']){
                $login_info = array(
                    "ResultCode" => 1,
                    "Message" => "You are connected!");

                    }else{
                    $login_info = array(
                        "ResultCode" => 2,
                        "Message" => "Wrong username or password");
                    }
            }
        }
    $json = json_encode($login_info);
echo $json;
?>

在光子面板中我放置了 Url mydomain/auth.php 而我没有放置任何可选的 Key/Value 对

不知道是什么问题,如果有人知道

I replied on our forum。在此处发布相同内容:

字母 "U" 暗示它可能来自 "Username does not exist."。 替换

die ("Username does not exist.");

$login_info = array(
                        "ResultCode" => 3,
                        "Message" => "Username does not exist."
                   );

如果问题仍然存在,请使用 postman 并向您的服务器发送带有正确查询字符串值的 HTTP 请求,然后查看它 returns。解决这个问题。