OAuth callback with php, what am I doing wrong?

Your URL is malformed

$url = 'https://id.twitch.tv/oauth2/token';

You you should be using cURL not file_get_contents. FGC is normally blocked from making HTTP requests on most providers for security reasons

Provides a PHP example

Line 38 onwards specifically