No Result for Reference User

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 '{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?

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('' . $userID);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Client-ID: YourClientID'));
$r = curl_exec($ch);
$json_obj  = json_decode($r);

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