48 lines
1.4 KiB
PHP
48 lines
1.4 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
class TwitchModel extends CI_Model {
|
|
|
|
public function getTwitchInfos($channel) {
|
|
$url = "https://api.twitch.tv/helix/users?login=" . $channel;
|
|
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
|
'client-id: e4iys1e969ndfyrdzuiae7whaact2p'
|
|
]);
|
|
curl_setopt($ch, CURLOPT_URL,$url);
|
|
$result=curl_exec($ch);
|
|
curl_close($ch);
|
|
|
|
return json_decode($result, true);
|
|
}
|
|
|
|
public function getTwitchStream($channel) {
|
|
$url = "https://api.twitch.tv/kraken/streams/" . $channel;
|
|
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_URL,$url);
|
|
$result=curl_exec($ch);
|
|
curl_close($ch);
|
|
|
|
return json_decode($result, true);
|
|
}
|
|
|
|
public function getTwitchVideos($channel) {
|
|
$url = "https://api.twitch.tv/kraken/channels/" . $channel . "/videos";
|
|
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_URL,$url);
|
|
$result=curl_exec($ch);
|
|
curl_close($ch);
|
|
|
|
return json_decode($result, true);
|
|
}
|
|
}
|