These are chat archives for arenanet/api-cdi

15th
Jan 2018
Quaggan BooOOoot
@QuagganBooOOoot
Jan 15 2018 05:30

Did something change with API?
by Reanne.5462 in API Development

`
<?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);

New discussion in API Development:
Werdes
@werdes
Jan 15 2018 10:54
has the /prices/ Endpoint always delivered an object on single id and an array on ?ids= ?
darthmaim
@darthmaim
Jan 15 2018 10:55
yes
all endpoints do that
Werdes
@werdes
Jan 15 2018 10:55
ah ok
thinking about that, php wouldn't care that much anyway
Eearslya Sleiarion
@Eearslya
Jan 15 2018 13:35
Yeah, I'm thinking that person has a fresh install of PHP that may not have HTTPS certs, which is why I told them to check their initial url grab.
smiley
@codemasher
Jan 15 2018 13:38
file_get_contents() should not be affected unless you use a stream context
they'll probably come back when they find out that this function hase its downsides... :D
Eearslya Sleiarion
@Eearslya
Jan 15 2018 13:39
I swear I once had an issue where PHP couldn't find a CA cert bundle so any https calls failed
smiley
@codemasher
Jan 15 2018 13:40
with curl, sure
darthmaim
@darthmaim
Jan 15 2018 13:40
nope, with php too
smiley
@codemasher
Jan 15 2018 13:40
i mean ext_curl
darthmaim
@darthmaim
Jan 15 2018 13:40
you have to set the correct path to the ca certs in the php_ini
yeah, even without ext_curl
if your os doesn't come with a default ca bundle for example
smiley
@codemasher
Jan 15 2018 13:41
like... windows
Eearslya Sleiarion
@Eearslya
Jan 15 2018 13:41
I mean, that wouldn't make sense.. if file_get_contents() worked without a CA cert bundle, that would mean that it doesn't bother verifying HTTPS.
darthmaim
@darthmaim
Jan 15 2018 13:41
nope, windows comes with certificates installed
Eearslya Sleiarion
@Eearslya
Jan 15 2018 13:41
of course it does
smiley
@codemasher
Jan 15 2018 13:42
CURLOPT_CAINFO
Eearslya Sleiarion
@Eearslya
Jan 15 2018 13:42
the only system I've ever had to manually install ca-certificates on was a barebones, basically-only-the-kernel install of debian
darthmaim
@darthmaim
Jan 15 2018 13:42
^
sometimes they are outdated though
might not include the root certificate for the api
Eearslya Sleiarion
@Eearslya
Jan 15 2018 13:43
yeah, which is why they made it an apt-get-able package
you have to set the cacaert manually because by default it's not set in php.ini
darthmaim
@darthmaim
Jan 15 2018 13:44
but you can set it
Eearslya Sleiarion
@Eearslya
Jan 15 2018 13:44
well then that's probably why they're having an issue with https
speaking of apt-get, when was the last time I did a security update...
smiley
@codemasher
Jan 15 2018 13:45
i don't have it set either. maybe php tries to acces the system certificates if theres no ca bundle
either way, file_get_contents('https://...') should work
darthmaim
@darthmaim
Jan 15 2018 13:46
nope, not when you don't have the correct certs...
smiley
@codemasher
Jan 15 2018 13:47
the cacert is only necessary for verification which could be skipped
verify_peer
darthmaim
@darthmaim
Jan 15 2018 13:48
so? There are 1000 ways to fix that problem... one of them just setting the correct path to the cert bundle
Eearslya Sleiarion
@Eearslya
Jan 15 2018 13:50
only necessary for verification which could be skipped
could; not default
we're not talking about the capabilities of file_get_contents(), we're talking about how it behaves out of the box
smiley
@codemasher
Jan 15 2018 13:51
by "could" i meant i don't know what php does internally
Eearslya Sleiarion
@Eearslya
Jan 15 2018 13:51
if PHP is at all sane, it would default to verifying
darthmaim
@darthmaim
Jan 15 2018 13:51
it definitely does not ignore certs by default
smiley
@codemasher
Jan 15 2018 13:52
TRUE by default as of cURL 7.10. Default bundle installed as of cURL 7.10.
darthmaim
@darthmaim
Jan 15 2018 13:52
no one is talking about curl
smiley
@codemasher
Jan 15 2018 13:53
the stream wrapper for file_get_contents depends on curl
darthmaim
@darthmaim
Jan 15 2018 13:54
file_get_contents works without having curl installed
(it does depend on openssl though when you try to access https)
smiley
@codemasher
Jan 15 2018 13:55
stream wrapper