Error 401: "Unauthorized" "invalid oauth token" when requesting user information

In that case as per

Trying using a header instead of Query String argument. I don’t think that still works…

So:

<?php
    $user = $_GET['userid'];
    
    $url = 'https://api.twitch.tv/kraken/user';
    
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 3);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Authorization: OAuth ' . $user
    ));
    
    $result = curl_exec($ch);
    curl_close($ch);

    echo $result;
?>

Use a HTTP header, and when using oAuth/bearers it’s safe to omit the clientID as clientID is determined from the oAuth provided