Hello guys!
I’m very new in API and also as developers
At first I try to find the answer on the forum and google without success 
I would like to add Twitch to my website with the New API.
My first step was to read the Documentation regarding API & Authentification Guide and then the Code samples available here: https://dev.twitch.tv/get-started
As I using Symfony 2.8, I took the PHP code which I adapted for Symfony as below (I’m really sorry to put my code like that):
My Twig view:
<div class="tab-pane fade" id="stream">
{{ render(controller('ISUStreamBundle:Stream:twitchConnexion') }}
</div>
My Controller:
/*
* @Route("/account_authorization/twitch", options={"expose"=true}, name="twitch_account_oauth")
*/
public function twitchConnexionAction(Request $request)
{
$provider = new TwitchProvider([
'clientId' => 'XXX', // The client ID assigned when you created your application
'clientSecret' => 'XXXX', // The client secret assigned when you created your application
'redirectUri' => 'XXXX', // Your redirect URL you specified when you created your application
'scopes' => ['user_read'] // The scopes you would like to request
]);
$session = $this->get('session');
// If we don't have an authorization code then get one
if (!isset($request->query->get('code')) {
// Fetch the authorization URL from the provider, and store state in session
$authorizationUrl = $provider->getAuthorizationUrl();
$session->set('oauth2state', $provider->getState());
// Display link to start auth flow
return $this->render('ISUStreamBundle:Buttons:twitch.html.twig', ['authorizationUrl' => $authorizationUrl]);
// Check given state against previously stored one to mitigate CSRF attack
} elseif (empty($request->query->get('state')) || (isset($session->get('oauth2state')) && $request->query->get('state') !== $session->get('oauth2state'))) {
if (isset($session->get('oauth2state'))) {
unset($session->get('oauth2state'));
}
return $this->render('ISUStreamBundle:error.html.twig');
} else {
try {
// Get an access token using authorization code grant.
$accessToken = $provider->getAccessToken('authorization_code', [
'code' => $request->query->get('code')
]);
// Using the access token, get user profile
$resourceOwner = $provider->getResourceOwner($accessToken);
$user = $resourceOwner->toArray();
echo '<html><table>';
echo '<tr><th>Access Token</th><td>' . htmlspecialchars($accessToken->getToken()) . '</td></tr>';
echo '<tr><th>Refresh Token</th><td>' . htmlspecialchars($accessToken->getRefreshToken()) . '</td></tr>';
echo '<tr><th>Username</th><td>' . htmlspecialchars($user['display_name']) . '</td></tr>';
echo '<tr><th>Bio</th><td>' . htmlspecialchars($user['bio']) . '</td></tr>';
echo '<tr><th>Image</th><td><img src="' . htmlspecialchars($user['logo']) . '"></td></tr>';
echo '</table></html>';
// You can now create authenticated API requests through the provider.
//$request = $provider->getAuthenticatedRequest(
// 'GET',
// 'https://api.twitch.tv/kraken/user',
// $accessToken
//);
} catch (Exception $e) {
return $this->render('ISUStreamBundle:error.html.twig',[
$e->getMessage()
]);
}
}
}
My issue is when I call my controller I got an error 500 from server without information (no symfony debugger, no console message, etc.)
Could you help me please?
Thanks in advanced.
Regards,
Fabien “Xutyr” C.