如何在Laravel中为后端API请求设置steamLoginSecure Cookie
Laravel实现Steam市场价格历史API调用
我正在开发一款个人应用,用于展示Steam市场单品的价格历史图表。调用Steam的价格历史API需要携带名为steamLoginSecure的Cookie,已有Python实现方案,但我的应用基于Laravel开发,需要用Laravel完成这个调用。
目标API示例链接:https://steamcommunity.com/market/pricehistory/?country=PT¤cy=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¤cy=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¤cy=1&appid=252490&market_hash_name=Fish%20Hammer")->withCookie(cookie('steamLoginSecure', 'xxx', 3600))->json(); });
注:代码中的xxx为Steam用户专属令牌
内容的提问来源于stack exchange,提问作者Jasper Erkel
相关产品推荐
相关产品推荐

