团结 - WWW class "couldn't connect to host"
Unity - WWW class "couldn't connect to host"
经过研究,我决定使用PHP通过网络播放器应用程序发送邮件,因为您无法在该平台上使用System.net.mail。
在 php 方面,一切都很好,我使用 swift 邮件程序和 gmail smtp。当文件被托管并且我通过浏览器调用它时它工作正常并发送邮件。
我在同一台服务器上托管我的 Web 应用程序,这是调用 php 脚本的 C# 代码:
public string phpUrl = "http://myAdress/sendMail.php";
public void SendMail ()
{
StartCoroutine(loadPhpMail());
}
private IEnumerator loadPhpMail()
{
WWW postPhp = new WWW (phpUrl);
yield return postPhp;
if (postPhp.error != null)
{
Debug.Log("error : "+postPhp.error);
}
else
{
if (postPhp.text=="true")
{
Debug.Log("success");
}
}
}
和行 "Debug.Log("错误:“+postPhp.error);” returns "error : couldn't connect to host".
我做了研究工作,但找不到解决方法。
我尝试了一些东西,比如向服务器添加跨域策略。
感谢大家阅读本文。
再见!
您的 URL 无效(它是亲戚 URL):myAdress/sendMail.php
您需要使用像这样的地址(单击 link 查看 WWW 的使用示例),带有 "http://" 前缀和完整的 URL,包括域名:
通过更改 ANSI 中 crossdomain.xml 的编码解决。
与错误消息无关,但无论如何都解决了。
谢谢大家
经过研究,我决定使用PHP通过网络播放器应用程序发送邮件,因为您无法在该平台上使用System.net.mail。
在 php 方面,一切都很好,我使用 swift 邮件程序和 gmail smtp。当文件被托管并且我通过浏览器调用它时它工作正常并发送邮件。
我在同一台服务器上托管我的 Web 应用程序,这是调用 php 脚本的 C# 代码:
public string phpUrl = "http://myAdress/sendMail.php";
public void SendMail ()
{
StartCoroutine(loadPhpMail());
}
private IEnumerator loadPhpMail()
{
WWW postPhp = new WWW (phpUrl);
yield return postPhp;
if (postPhp.error != null)
{
Debug.Log("error : "+postPhp.error);
}
else
{
if (postPhp.text=="true")
{
Debug.Log("success");
}
}
}
和行 "Debug.Log("错误:“+postPhp.error);” returns "error : couldn't connect to host".
我做了研究工作,但找不到解决方法。 我尝试了一些东西,比如向服务器添加跨域策略。
感谢大家阅读本文。 再见!
您的 URL 无效(它是亲戚 URL):myAdress/sendMail.php
您需要使用像这样的地址(单击 link 查看 WWW 的使用示例),带有 "http://" 前缀和完整的 URL,包括域名:
通过更改 ANSI 中 crossdomain.xml 的编码解决。 与错误消息无关,但无论如何都解决了。 谢谢大家