Jump to content
  • Sign Up

Did something change with API?


Reanne.5462

Recommended Posts

<?php             $url = "https://api.guildwars2.com/v2/commerce/prices/19684";             $string = file_get_contents($url); $next = json_decode($string, true); $response = array($next);             foreach ($response as $value) {             echo var_dump($value);             } 

This results in NULL instead of the expected results. Why? What has changed since last time I was working on this API?

Link to comment
Share on other sites

eearslya@chimera ~ $ php temp.phparray(4) {  ["id"]=>  int(19684)  ["whitelisted"]=>  bool(false)  ["buys"]=>  array(2) {    ["quantity"]=>    int(362705)    ["unit_price"]=>    int(79)  }  ["sells"]=>  array(2) {    ["quantity"]=>    int(1887746)    ["unit_price"]=>    int(95)  }}

Works just fine for me. First thing I'd do is dump $string to the console, and make sure that you're not encountering an error with file_get_contents().

Link to comment
Share on other sites

Should work as expected, except that the API times out every now and then so that file_get_contents() returns false and everything breaks.Check if there's a valid response like so:

$response = file_get_contents('https://api.guildwars2.com/v2/commerce/prices/19684');if($response !== false){    $response = json_decode($response);    foreach($response as $key => $value) {        var_dump(['key' => $key, 'value' => $value]);    }}else{    // handle error}
Link to comment
Share on other sites

@Reanne.5462 said:I'm not gonna be able to do this using localhost anymore am I? Am I right in that I will need a Server Certificate?

You won't need a server certificate and you still should be able to use it for local network purposes. Not exactly sure why you think this wouldn't work. Been doing similar with my own stuff and works fine.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...