I am running into some issues grabbing the $followers when I echo this in my index.php, it just doesnt respond. I have my clientID defined in my config.php same with $twitch_username
$channels = 'https://api.twitch.tv/kraken/channels/' . $twitch_username; $ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_HTTPHEADER => array( 'Client-ID: ' . $clientId ), CURLOPT_RETURNTRANSFER => true, CURLOPT_URL => $channels . $twitch_username )); $cexecute = curl_exec($ch); $twitch = json_decode($cexecute,true); $display_name = $twitch['display_name']; $game = $twitch['game']; $status = $twitch['status']; $url = $twitch['url']; $avatar = $twitch['logo']; $views = $twitch['views']; $followers = $twitch['followers']; curl_close($ch);
Any tips? or suggestions to get this fixed?
Add error checking and echo out potential errors. Currently, you’re assuming that curl_exec is returning with no error.
I have the following in my index.php
This produced errors with something not defined in my config.php, nothing related to TwitchAPI.After resolving that it produced an erro with my Twitch API, stating
curl_close($ch); is not a valid response.
Those ini_set calls are for PHP configuration. I’m speaking to checking cURL object directly and taking action on that. Docs on the PHP site: http://php.net/manual/en/function.curl-error.php
No errors, cUIRL works no issue as I used it before this client id needed
- I did verify using what you linked
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.