function checkAuthResult() { $oauthToken = getVariable('oauth_token', FALSE); $oauthVerifier = getVariable('oauth_verifier', FALSE); /** @var \AABTest\OauthRequestToken $oauthRequest */ $oauthRequest = getSessionVariable('oauthRequest', null); if (!$oauthToken || !$oauthVerifier || !$oauthRequest) { return; } if ($oauthToken != $oauthRequest->oauthToken) { //Miss-match on what we're tring to validated. return; } try { $oauthConfig = new OauthConfig(FLICKR_KEY, FLICKR_SECRET); $oauthService = new \ArtaxApiBuilder\Service\FlickrOauth1($oauthConfig); $oauthService->setOauthToken($oauthRequest->oauthToken); $oauthService->setTokenSecret($oauthRequest->oauthTokenSecret); $api = new \AABTest\FlickrAPI\FlickrAPI(FLICKR_KEY, $oauthService); $command = $api->GetOauthAccessToken($oauthVerifier); $oauthAccessToken = $command->execute(); setSessionVariable('oauthAccessToken', $oauthAccessToken); echo "Oauth is confirmed - username is:" . $oauthAccessToken->user->username; } catch (\AABTest\FlickrAPI\FlickrAPIException $fae) { echo "Exception processing response: " . $fae->getResponse()->getBody(); } }
function showFlickrStatus(\AABTest\OauthAccessToken $oauthAccessToken) { $oauthConfig = new OauthConfig(FLICKR_KEY, FLICKR_SECRET); $oauthService = new \ArtaxApiBuilder\Service\FlickrOauth1($oauthConfig); $oauthService->setOauthToken($oauthAccessToken->oauthToken); $oauthService->setTokenSecret($oauthAccessToken->oauthTokenSecret); $api = new \AABTest\FlickrAPI\FlickrAPI(FLICKR_KEY, $oauthService); $command = $api->flickrTestLogin(); $loginInfo = $command->execute(); echo "User ID: " . $loginInfo->user . "<br/>"; echo "User name: " . $loginInfo->username . "<br/>"; }