My 3 function to get data:
public function getTwitch($url){
$channelsApi = $url;
$channelName = 'twitch';
$clientId = 'xxx';
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_HTTPHEADER => array(
'Client-ID: ' . $clientId,
'Accept: application/vnd.twitchtv.v4+json'
),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => $channelsApi . $channelName
));
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
I choose type of data:
public function getApiUri($type) {
$apiUrl = "https://api.twitch.tv/kraken";
$apiCalls = array(
"streams" => $apiUrl."/streams/",
"search" => $apiUrl."/search/",
"channel" => $apiUrl."/channels/",
"user" => $apiUrl."/user/",
"teams" => $apiUrl."/teams/",
"clips" => $apiUrl."/clips/",
);
return $apiCalls[$type];
}
And I try to get Clip’s data:
public function GetClip($url) {
$s = $this->getTwitch($this->getApiUri("clips").$url);
//$json = json_decode($s, true);
return $s;
}
return $s is temporary
And… for example:
$clip->GetClip(‘playhearthstone/HelpfulYakBigBrother’);