That request works for me in the offline scenario. I’ll have to try when one or the other is online. I’m assuming you’re passing in a Client-ID and getting a full response, right? And this happens with every request?
As an aside, I wouldn’t recommend using those two configurations. The cache-control isn’t respected for performance reasons, and the load balancer likely puts you in the same data center in the new connections case.
As an aside, if I access the url passed to this function and tack on the &client_id=… the results are correct (shows a result ONLY for the channels I specify. I’m only seeing this behaviour (returns 25 results regardless of how many channels I specify) when I access the endpoint via PHP.
To confuse things even more, if I do this all through PHP’s file_get_contents it works perfectly fine.
The presence of the content-type doesn’t make a difference, but I’ve removed it as per your recommendation. I am still getting 25 results rather than the 3 I am requesting results for. Again, this only happens with PHP’s curl_exec. If I use file_get_contents() it works as expected (max of 3 results depending on who’s online).
I don’t see your code setting Client-ID. Are you copying and pasting your exact code? If I set $client_id in getCurl, I only get a single response back. Here is the truncated var_dump showing a single response:
Pardon, I modified the code slightly when pasting. line 6 - CURLOPT_HTTPHEADER => ['Client-ID: '.$client_id],
was meant to say $GLOBALS[‘twitch_client_id’]; Clearly it’s working because I’m getting results, right? It’s set to error out if there is no client id. I’m wondering if it’s some local php.ini setting that’s blocking this?
I’m not sure if this is related to your issue exactly, but I actually had a similar problem with my PHP JSON format. It wasn’t limiting to a certain amount of results, which I wanted. It turned out it wasn’t the Twitch API, but more the json_decode variable I had set. I can’t remember exactly but I believe it was one of the “curl_setopt” functions that had caused my issue.
Here’s what I needed to get it working:
Your code is certainly working. I copy and pasted it directly into my editor and ran it locally. I still only get one result (kripp is offline and AGDQ is online), which is expected. I can’t reproduce getting 25 back every call. Can you copy and paste a var_dump from the code above?
I wonder if this is a configuration in PHP that is set on and off depending on how it was installed? I’m using MAMP, so it might default to including that option. Thanks for the help, @MadMikeGamerXL1! Good tip for other folks that may run into this.