/**
* get access token of from service, has to be called after successful authorization
*
* @param string $code optional, if no code given method tries to get it out of $_GET
*/
public function getAccessToken($code = null)
{
if (!$code) {
if (!isset($_GET['code'])) {
throw new Exception('could not retrieve code out of callback request and no code given');
}
$code = $_GET['code'];
}
$parameters = array('code' => $code, 'client_id' => $this->_client->getClientKey(), 'client_secret' => $this->_client->getClientSecret(), 'redirect_uri' => $this->_client->getCallbackUrl(), 'grant_type' => 'authorization_code');
$http = new HttpClient($this->_configuration->getAccessTokenEndpoint(), 'POST', http_build_query($parameters));
//$http->setDebug(true);
$http->execute();
$this->_parseAccessTokenResponse($http);
}