gpt4 book ai didi

javascript - Steam 发布请求 - 无法加载资源 : the server responded with a status of 400 (Bad Request)

转载 作者:数据小太阳 更新时间:2023-10-29 04:21:31 31 4
gpt4 key购买 nike

我正在尝试发送这样的帖子请求:

xhr.open("POST", "/steamapi/actions/RemoveFriendAjax", false);
var params = "sessionID="+session_id+"&steamid="+id;
xhr.onreadystatechange = function() {//Call a function when the state changes.
if(xhr.readyState == 4 && xhr.status == 200) {
alert(xhr.responseText);
}
}
xhr.send(params);

我正在使用 Apache 服务器,这是我的 .htaccess 文件

RewriteEngine On
RewriteRule ^api/(.*)$ http://api.steampowered.com/$1 [P]
RewriteRule ^(.*)$ http://steamcommunity.com/$1 [P]
<IfModule mod_headers.c>
Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
</IfModule>

每当我发送请求时,我都会收到此错误:

Failed to load resource: the server responded with a status of 400 (Bad Request) 
enter code here

为什么会这样?我在 Steam 上使用了 GET 请求,它们工作正常,但这个 POST 请求似乎不起作用。

编辑:这是 steamcommunity.com 的 robot.txt 文件:

User-agent: *
Disallow: /actions/
Disallow: /linkfilter/
Host: steamcommunity.com

它说 Disallow:/actions/,这就是我收到 400 错误的原因吗?

最佳答案

您是否使用了setRequestHeader

xhr.open("POST", "/steamapi/actions/RemoveFriendAjax", false);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

关于javascript - Steam 发布请求 - 无法加载资源 : the server responded with a status of 400 (Bad Request),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25596961/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com