我正在尝试创建一个从minecraft服务器创建的数据库中获取统计信息的网站。我将uuid插入mojangs API并以用户名形式出现时出现问题。当您第一次访问该站点时它会起作用,但是当您刷新它时会出现错误:
Warning: file_get_contents(https://sessionserver.mojang.com/session/minecraft/profile/07eb744f35b74ac083e90e0377a5a967): failed to open stream: HTTP request failed! HTTP/1.1 429 429 in C:\xampp\htdocs\index.php on line 47
Notice: Trying to get property of non-object in C:\xampp\htdocs\index.php on line 49
Warning: file_get_contents(https://sessionserver.mojang.com/session/minecraft/profile/f5cf9ff1b9a74176983bb8b1d0c0ee70): failed to open stream: HTTP request failed! HTTP/1.1 429 429 in C:\xampp\htdocs\index.php on line 47
Notice: Trying to get property of non-object in C:\xampp\htdocs\index.php on line 49
Warning: file_get_contents(https://sessionserver.mojang.com/session/minecraft/profile/07eb744f35b74ac083e90e0377a5a967): failed to open stream: HTTP request failed! HTTP/1.1 429 429 in C:\xampp\htdocs\index.php on line 47
Notice: Trying to get property of non-object in C:\xampp\htdocs\index.php on line 49
Warning: file_get_contents(https://sessionserver.mojang.com/session/minecraft/profile/f5cf9ff1b9a74176983bb8b1d0c0ee70): failed to open stream: HTTP request failed! HTTP/1.1 429 429 in C:\xampp\htdocs\index.php on line 47
Notice: Trying to get property of non-object in C:\xampp\htdocs\index.php on line 49
在我刷新之后,名字从桌子上消失了,它给了我那些错误。我真的需要尽快解决这个问题!
顺便说一句,我用***替换了密码,但在真正的密码中,它的工作方式不是问题所在。这么多提前!
答案 0 :(得分:0)
429 HTTP错误意味着您向服务器发送了太多请求(在您的情况下为sessionserver.mojang.com)。
您必须处理限制这一事实非常令人期待,因为从MySQL读取速度非常快,并且您的服务器每秒都会发出许多请求来获取数据。您需要在查询之前添加延迟以解决此问题(反过来,这可能会减慢页面加载速度)。因此,我还建议您缓存接收的数据,而不是每次请求页面时再次下载。