0

I'm messing around and creating a website that uses Steam API to log in. I'm currently trying to load the users inventory into the website without any greater success and can't find the problem. If I open the link normally in a web browser it works without any problems.

I have tried multiple different urls without success.

Here's an example of the code:

<?php

// Replace STEAM_ID with the Steam ID of the player whose inventory you want to retrieve
$steamid = "STEAM_ID";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://steamcommunity.com/profiles/$steamid/inventory/json/730/2");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_ENCODING, '');

// Execute the cURL request and fetch the response
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
echo $response;
// Close the cURL session
curl_close($ch);

$response_data = json_decode($response, true);
$inventory = $response_data['rgDescriptions'];
print_r($inventory);

echo "HTTP status code $http_code\n";

Output: {"success":false,"Error":"Unsupported request"}Error: HTTP status code 403

I have also googled and tried different solutions without any different outcome sadly.

1 Answers1

0

I tried using this endpoint as my url and it worked. Maybe try implementing this in your code to see if you get a response

https://steamcommunity.com/inventory/{}/730/2