@Tharmadawe Tharmadawe
Thats what i just have done but now im getting this through out my site.
Parse error: syntax error, unexpected ‘public’ (T_PUBLIC) in /home/content/a2pnexwpnas03_data03/96/3342496/html/wp-content/plugins/TwitchWP/inc/Twitch.php on line 3
And this is the code now.
<?php class Twitch { public function getContents($url) { $clientID = 'axjhfp777tflhy0yjb5sftsil'; $opts = array( 'http' => array( 'method' => "GET", 'header' => "Client-ID: $clientID" ) ); $context = stream_context_create($opts); return file_get_contents($url, false, $context); } 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/", "games" => $apiUrl."/games/top", "search" => $APIURL."/search/" ); return $apiCalls[$type]; } public function getFeatured($game) { $s = $this->getContents(($this->getApiUri("streams")."?game=".urlencode($game)."&limit=1&offset=0"); $activeStreams = json_decode($s, true); $streams = $activeStreams["streams"]; foreach($streams as $stream) { return $stream["channel"]["name"]; } } public function getGames($amt) { $s = $this->getContents(($this->getApiUri("games")."?limit=$amt&offset=0"); $activeGames = json_decode($s, true); $games = $activeGames["top"]; return $games; } public function getStreams($game, $page, $limit, $dopg) { $offset = ($page-1)*$limit; $total = floor($activeStreams["_total"]/$limit); //Pagination $nextPage = $page+1; $paginate = ""; if($page>1) { $prevPage = $page-1; $pageinate .= "< Previous Page"; } $pageinate .= "Next Page >"; //Streams $s = $this->getContents(($this->getApiUri("streams")."?game=".urlencode($game)."&limit=$limit&offset=$offset"); $activeStreams = json_decode($s, true); $streams = $activeStreams["streams"]; $final = ""; foreach($streams as $stream) { $imgsm = $stream["preview"]["small"]; $imgmed = $stream["preview"]["medium"]; $viewers = $stream["viewers"]; $channel = $stream["channel"]; $status = substr($channel["status"],0,40)."[...]"; $twitchName = $channel["name"]; $twitchDisplay = $channel["display_name"]; $twitchLink = $channel["url"]; $final .= "".$pageinate."
";
}
return $final;
}
public function getUserStreams2($channels, $showOffline) {
//Pull Stream Data
$stream = $this->getContents(($this->getApiUri("streams")."?channel=".$channels);
$streamData = json_decode($stream, true);
$online = array();
$channelArray = explode(",", $channels);
if($streamData["_total"] > 0) {
foreach($streamData["streams"] as $key=>$value){
$name = strtolower($value["channel"]["name"]);
//Set Channel to Online
$online[$name]["stream"] = $value;
}
}
foreach ($channelArray as $channel) {
$oc = $online[$channel];
if($oc) {
$imgsm = $oc["stream"]["preview"]["small"];
$imgmed = $oc["stream"]["preview"]["medium"];
$viewers = $oc["stream"]["viewers"];
$ch = $oc["stream"]["channel"];
$status = substr($ch["status"],0,40)."[...]";
$twitchName = $ch["name"];
$twitchDisplay = $ch["display_name"];
$twitchLink = $ch["url"];
//$final.=json_encode($oc);
$final .= "