I don't know show api streamer

hi i have problem to show 30 streamer with api, just show 1 streamer can you help me?

<?php

$_POST = $_GET; 


function is_channel_live($channel) {    
    include('config.php');
	$request = json_decode(file_get_contents_curl( $TwitchApiStream ));
        $request2 = json_decode(file_get_contents_curl( $TwitchApiUsers ));
  
   
    echo('<link rel="stylesheet" type="text/css" href="style/streamer.css">');
  
    $tum = $request->data[0]->thumbnail_url;
    $tum2 = str_replace("{width}x{height}", "1920x1080", "$tum");
    
 echo ("<br><div class='StreamBorder'>");
   echo ("<a href='https://www.twitch.tv/". $request->data[0]->user_name  ."' >");
   echo ("<div class='StreamerLiveTxt'>Live</div>");
   echo ("<img class='StreamerBanner' src='". $tum2 ."'</img>");
   echo ("<div class='StreamerTitle'>". $request->data[0]->title ."</div>"); 
   echo ("<div class='StreamerName'>". $request->data[0]->user_name ."</div>");
   echo ("<div class='StreamerGame'>". $request->data[0]->game_name ."</div>");
   echo ("<div class='StreamerViewer'>". $request->data[0]->viewer_count ."</div>");
   echo ("<img class='StreamerProfile' src='". $request2->data[0]->profile_image_url ."'</img>");
   echo ("<img class='StreamerGamepic' src='". $game2 ."'</img>");
   echo ("</a>");
 echo("</div>");
  




}   
     
if(is_channel_live($_POST)) {
    echo "";
} else {
    echo "";
}
     


          

function file_get_contents_curl($url) {
    include('config.php');

	$curlHeader = array(
		"Client-ID: ". $TwitchClientId , 
		"Authorization: Bearer ". $TwitchToken , 
		"Accept: application/vnd.twitchtv.v5+json"
	);
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
	curl_setopt($ch, CURLOPT_HTTPHEADER, $curlHeader);
	$data = curl_exec($ch);
	curl_close($ch);
	
	return $data;
}

?>

my config.php


my preview
unknown
pls help me

It only shows one user, as you only looked up one user.

You told your tool/website/page to only lookup and display streamerhouse so change yoru URL’s to match the 30 you want to lookup.

Both Get Users and Get Streams Support looking up multiple users at once.

So, for example:

https://api.twitch.tv/helix/streams?user_login=foo&user_login=bar
https://api.twitch.tv/helix/users?login=foo&login=bar

tank you i change to this

$TwitchApiStream = 'https://api.twitch.tv/helix/streams?user_login=VenusWorld&user_login=maxadrums';
$TwitchApiUsers = 'https://api.twitch.tv/helix/users?login=VenusWorld&login=maxadrums';```

but again show 1 stream

Your PHP code doesn’t have a loop.
It only pulls the first stream. ($request->data[0])

:sweat_smile: can you help me to show all :rofl:

There are a few solutions that work here but you need to link two API call responses to each other when the order of results in both outputs may not match.

So you’ll need to devise what works best for your script here and make your own changes as needed.

Throwing in a simple foreach loop isn’t gonna cut it to add the users avatar to their stream output.

So you’ll need to preprocess the output from the two API calls and merge the data before looping the returned records.

ooo tank you i test :hearts:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.