Get results of API Requests in PHP

I’m using the PHP authentication examples from TwitchDev’s Github account.

I can’t figure out how to output the results of API requests in any way. The example uses

// You can now create authenticated API requests through the provider.
//$request = $provider->getAuthenticatedRequest(
//    'GET',
//    'https://api.twitch.tv/kraken/user',
//    $accessToken
//);

but how do I then access that output? I can’t just use echo nor can I put it into an array like the example of getResourceOwner()

// Using the access token, get user profile
$resourceOwner = $provider->getResourceOwner($accessToken);
$user = $resourceOwner->toArray();

echo '<tr><th>Username</th><td>' . htmlspecialchars($user['display_name']) . '</td></tr>';

and simply modify based on what the array should contain, based on API documentation.

How does getAuthenticatedRequest() work?

// starts a commented line, the whole request is commented out so the code never runs. Uncomment it and you can then inspect the contents of $request with var_dump or var_export, for example.

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