This will have the API search for games matching Overwatch, and limit the results to the first 25. The order is by viewer count. Therefore, limiting to 25 you will get the top 25 most viewed streams (matching your search)in descending order.
doing a foreach loop through the 25 results we can store values from each stream. I grab the display_name (user’s set case of name) the name (lowercase version of the name) and a preview panel to be used (i used medium for the example)
Use it as matt_thomas suggested: $streams = json_decode(get_url_contents("https://api.twitch.tv/kraken/streams/?game=Overwatch&limit=25&client_id=xxxxxxxxxxxxxxxxxxxxxxxx"));
Then just view what it spits out: print_r($streams);
I found my issue, I was working in localhost so I had to type:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
probably you have the same issue, try it, thank you very much @matt_thomas for the support, you help me a lot <3
This issue stems from not having the specific CA in a CA bundle available for the cURL library (Or OpenSSL, though OpenSSL usually has this). You can grab any CA Bundle and apply it with:
// Replace the path here with the actual path for your CS bundle
$CABundlePemPath = realpath(__DIR__ . '/../cabundle.pem')
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_CAINFO, $CABundlePemPath);
The CA Bundle I use (Extracted from the FireFox browser source) is located here.
Now note that, while the solution you have here does work, it also means your server will not verify that api.twitch.tv is actually api.twitch.tv, meaning anyone can generate a cert and sit between you and the actual API and fake being the Twitch API to harvest tokens. I would recommend always verifying the peer as a safety measure for your OAuth tokens.