<h3>OAuth 2 Authorization Example</h3> <?php // print any error from Constant Contact that occurs during the authorization process if (isset($_GET['error'])) { echo '<span class="label label-important">OAuth2 Error!</span>'; echo '<div class="container alert-error"><pre class="failure-pre">'; echo 'Error: ' . $_GET['error']; echo '<br />Description: ' . $_GET['error_description']; echo '</pre></div>'; die; } // If the 'code' query parameter is present in the uri, the code can exchanged for an access token if (isset($_GET['code'])) { try { $accessToken = $oauth->getAccessToken($_GET['code']); } catch (OAuth2Exception $ex) { echo '<span class="label label-important">OAuth2 Error!</span>'; echo '<div class="container alert-error"><pre class="failure-pre">'; echo 'Error: ' . $ex->getMessage(); echo '</pre></div>'; die; } echo '<span class="label label-success">Access Token Retrieved!</span>'; echo '<div class="container alert-success"><pre class="success-pre">'; print_r($accessToken); echo '</pre></div>'; } else { ?> <!-- If the 'code' query parameter is not present, display the link the user needs to visit to initiate the oauth flow --> <button class="btn btn-primary" type="button"