Problems with users API with helix

Hey everyone,

I am attempting to pull in user information by login and am running into some trouble. When I run the following: https://api.twitch.tv/helix/users?login=Xpecial - I get back mostly what I expect {"data":[{"id":"30080741","login":"xpecial","display_name":"Xpecial","type":"","broadcaster_type":"partner","description":"Info","profile_image_url":"url","offline_image_url":"","view_count":24286677}]}1

I am attempting to figure out why the random 1 is returning at the end, I am new to this but it seems odd.

I am also attempting to pull in multiple users in one request with: https://api.twitch.tv/helix/users?login=Xpecial,BunnyFuFuu - in this case I instead receive {"data":[]}1

Does anyone know why I am getting the 1 at the end of both? Additionally, am I doing something wrong with my request for multiple users?

Thank you for any help you can provide with this!

Could you provide some code of how you make your API calls. It’s kinda hard to troubleshoot without that.

From the docs:

Request parameters are &-repeated (e.g., &login=&login=&login=), not comma-separated as in Twitch API v5.

Of course I miss the obvious information at the top of the page… Thank you for pointing me to that.

Regarding the call to it this is what I am sending:
`function get_newtwitchapi_curl($url) {
global $appID, $appSecret;
$curlHeader = array(
"Client-ID: " . $appID,
"Authorization: " . $appSecret
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $curlHeader);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
curl_close($ch);
return $data;

}`

I found the problem, was missing: curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

Without that option $data was being set to true and the curl response was being echo’ed out as it arrived.

2 Likes

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