You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Laravel中为后端API请求设置steamLoginSecure Cookie

Laravel实现Steam市场价格历史API调用

我正在开发一款个人应用,用于展示Steam市场单品的价格历史图表。调用Steam的价格历史API需要携带名为steamLoginSecure的Cookie,已有Python实现方案,但我的应用基于Laravel开发,需要用Laravel完成这个调用。

目标API示例链接:
https://steamcommunity.com/market/pricehistory/?country=PT&currency=3&appid=730&market_hash_name=Falchion%20Case

我尝试了以下两段代码,但都没达到预期效果:

尝试代码1

Route::get('/getPriceHistory/{marketHashName}', function ($marketHashName) {
    $cookie = Cookie::make('steamLoginSecure', 'xxx', 3600);
    return Http::get("https://steamcommunity.com/market/pricehistory/?country=US&currency=1&appid=252490&market_hash_name=Fish%20Hammer")->headers->setCookie($cookie)->json();
});

尝试代码2

Route::get('/getPriceHistory/{marketHashName}', function ($marketHashName) {
    return Http::get("https://steamcommunity.com/market/pricehistory/?country=US&currency=1&appid=252490&market_hash_name=Fish%20Hammer")->withCookie(cookie('steamLoginSecure', 'xxx', 3600))->json();
});

注:代码中的xxx为Steam用户专属令牌


内容的提问来源于stack exchange,提问作者Jasper Erkel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.14 22:50:31