- Home /
Question by
foruniv00 · Mar 12 at 07:10 PM ·
photonpost processingpost
How can I post Player's name to http ?
Hello. I used Photon Network to make a multiplay game. And I want to post player's name which made of PhotonNetwork. Nickname class to http. I use this code.
IEnumerator Upload()
{
byte[] myData = System.Text.Encoding.UTF8.GetBytes(PhotonNetwork.NickName);
UnityWebRequest www = UnityWebRequest.Put("https://...", myData);
yield return www.SendWebRequest();
if (www.result != UnityWebRequest.Result.Success)
{
Debug.Log(www.error);
}
else
{
Debug.Log("Upload complete!");
}
}
But it gives me to HTTP/1.1 405 Method Not Allowed error. I checked my http server many times. Is there something wrong or can't use this class for post player's name to http ? I will really appreciate anything useful tips. Thank you.
Comment
Best Answer
Answer by rh_galaxy · Mar 12 at 07:55 PM
PUT is generally not allowed on web-hotel webservers, but you can use GET with parameters or POST.
You can do it like this:
string url = "https://.../name_init.php?Name=" +
UnityWebRequest.EscapeURL(PhotonNetwork.NickName);
UnityWebRequest www = UnityWebRequest.Get(url);
yield return www.SendWebRequest();
But you need to of course create that page on the web server and use the data in some way.
Your answer
![](https://koobas.hobune.stream/wayback/20220613054118im_/https://answers.unity.com/themes/thub/images/avi.jpg)