No Result for Reference User


#1

Hey,
I’m trying to get the Users Broadcaster-Type by using shell_exec. But I dont get a response.

public function testpartner($UserIDCP){
     $urll =  shell_exec ("curl -H 'Client-ID: MyClientID' \
	-X GET 'https://api.twitch.tv/helix/users?id={UserIDCP}'");
	$json_obj = json_decode($urll);
	$partna = $json_obj->data[0]->broadcaster_type;
	}

With $UserIDCP I get the User-ID and thats correct. I checked it.
But if i want to print $partna I dont get a response. Is it a server failure or ist there a mistake in my code?


#2

PHP right?

Don’t use shell exec (it’s a security risk and that is likely your issue as it’s security blocked)

Use cURL naively instead, for example:

$ch = curl_init('https://api.twitch.tv/helix/users?id=' . $userID);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Client-ID: YourClientID'));
$r = curl_exec($ch);
curl_close($ch);
$json_obj  = json_decode($r);

closed #3

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