Initial commit as of 2018-10-16
This commit is contained in:
47
application/models/TwitchModel.php
Normal file
47
application/models/TwitchModel.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user