$account_is_logged_in = (bool) db_query_range
(
'SELECT 1 FROM {sessions} WHERE uid = :uid AND timestamp > :timestamp',
0,
1,
array
(
':uid' => $row->uid,
':timestamp' => REQUEST_TIME - (60 * 1),
)
)->fetchField();
$channelsApi = 'https://api.twitch.tv/helix/streams?client_id=*****&user_login=';
$result = db_select('field_data_field_twitch_username', 'r')
->fields('r')
->condition('entity_id',$row->field_twitch_username)
->execute()
->fetchAssoc();
$channelName=$result['field_twitch_username_value'];
$clientId = '*****';
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_HTTPHEADER => array(
'Client-ID: ' . $clientId,
'Authorization: Bearer *****',
),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => $channelsApi.$channelName
));
$response = curl_exec($ch);
curl_close($ch);
$result=json_decode($response);
$offline=TRUE;
if($result->data[0]->type=='live'){$offline=FALSE;}
return $offline;
Hello,
Im using this code to display my livestream and people of my clan on my website, but somehow twitch changes smth and i have to recode the code every week or smth…
this code checks whos online on twitch… if he has the twitchstreaemer role on the website and when he does the stream comes automaticly on my homepage.
but somehow twitch changes stuff and i have to figure out what changed and recode the thing wich cost me ages of time to fix (not a pro in coding).
can one of u tell me what i can change so i dont have to recode all the time?.
im using drupal btw.
thanks!