我有一个Java的蒸汽贸易机器人,它阅读等待的贸易报价从蒸汽,并拒绝他们的要求。我正在使用官方的Web (使用来自http://steamcommunity.com/dev/apikey的API密钥)来将请求传递给蒸汽公司。变量trade来自我自己的API (我已经调试了这个接口,并为拒绝报价而工作)。
SteamPlug.steamRequest(method, query);只是一个基本的HTTP请求者:
public static String steamRequest(String method, String query) {
try {
URL obj = new URL(query);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod(method);
int responseCode = con.getResponseCode();
if (responseCode != 200 && responseCode != 201) {
return "ERR" + responseCode;
}
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuilder response = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
return response.toString();
} catch (MalformedURLException | ProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
// Ignored
}
return null;
}这就是它拒绝贸易提议的方式:
SteamPlug.steamRequest(
"POST",
"http://api.steampowered.com/IEconService/DeclineTradeOffer/v0001/?key="
+ SteamPlug.API_KEY + "&tradeofferid=" + trade.getTradeOfferId()
);我想做的也是接受交易。我试过这样做:
SteamPlug.steamRequest(
"POST",
"https://steamcommunity.com/tradeoffer/" + trade.getTradeOfferId() + "/accept?key="
+ SteamPlug.API_KEY
);但我收到了411 Length Required的回复。
我相信我可以通过使用蒸汽会话认证来接受报价,但是是否可以只使用用户的Web密钥接受交易报价呢?
发布于 2015-09-30 07:21:34
你读过蒸汽API文档吗?没有交易接受函数,所以我假设您不能通过API接受交易。您的选择是检查SteamBot的贸易函数(尽管它是用C#编写的),并考虑直接发送到蒸汽站点的http请求(我相信有正确的蒸汽认证)。我自己正在写一个机器人,现在唯一能阻止我的东西--接受交易。
https://stackoverflow.com/questions/32300321
复制相似问题