Can't get json info to output

Good day all, I’m trying to extract some data from a website’s API. If I take the result from the webpage and put it in to a .json file and call it instead of the url it works fine but with the url it’s not working, so I’m thinking it must either be a url formatting error or I’m using the wrong function. I know from my limited experience that php is really finnicky about characters in strings.

The key is private so I just replaced it for the forum with INSERTKEYHERE but when I’m requesting it I have my API key in the url.

Any help would be appreciated. :slight_smile:

[php]<?php

$url = "https://opskins.com/api/user_api.php?request=GetLowestSalePrices&key=INSERTKEYHERE&appid=440&contextid=2&delimiter,&names=A+Rather+Festive+Tree,A+Whiff+of+the+Old+Brimstone";

$jsonData = file_get_contents($url);
$json = json_decode($jsonData, true);

echo $json['result']['appid'];

?>[/php]

PM me the key so I can test it out.

There is nothing wrong with the code. I get a result of 440 as it should.

Hmmm, maybe it’s my browser then.

Thanks for your help. :slight_smile:

You need to determine why your code isn’t working on your server.

Do you have php’s error_reporting set to E_ALL and display_errors set to ON, so that php would report and display all the errors it detects?

In order for the posted code to work, and work with a https url, your php installation would need two things -

  1. The php allow_url_fopen setting must be set to a true value.

  2. Php must be built with the openssl extension and it must be enabled in the php.ini.

There should be php errors when you run your code associated with each of these requirements.

It’s EasyPhP so I’ll have to dig into why it isn’t working. I just set it up with the default settings so I’ll have to dig into the guts of it later.

Sponsor our Newsletter | Privacy Policy | Terms of Service