/** * Fetch an access token. Sets the token for this object with the fetched token. * * The object should be initialized with the consumer token and user access token. * * @param string $oauth_verifier * The 'oauth_verifier' that was sent back in the callback URL after the authorization step. * @return array * An associative array containing the token, secret and callback confirmed status. * Array keys are 'oauth_callback_confirmed', 'oauth_token' and 'oauth_token_secret'. * * @throws CultureFeed_ParseException * If the result could not be parsed. */ public function getAccessToken($oauth_verifier) { $response = $this->oauth_client->authenticatedPost('accessToken', array('oauth_verifier' => $oauth_verifier)); $token = OAuthUtil::parse_parameters($response); if (!isset($token['oauth_token']) || !isset($token['oauth_token'])) { throw new CultureFeed_ParseException($response, 'token'); } $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']); return $token; }
/** * {@inheritdoc} */ public function generateFinancialOverviewReport(DateTime $start_date, DateTime $end_date, $consumer_key_counter = NULL) { $data = array('startDate' => $start_date->format(DateTime::W3C), 'endDate' => $end_date->format(DateTime::W3C)); if ($consumer_key_counter) { $data['balieConsumerKey'] = $consumer_key_counter; } $result = $this->oauth_client->authenticatedPost('uitpas/report/financialoverview/organiser', $data); $response = CultureFeed_Response::createFromResponseBody($result); if ($response->getCode() !== 'ACTION_SUCCEEDED') { throw new RuntimeException('Expected response code ACTION_SUCCEEDED, got ' . $response->getCode()); } // Extract the reportId from the relative URL we get back. // Example: // /uitpas/report/financialoverview/organiser/19/status?balieConsumerKey=31413BDF-DFC7-7A9F-10403618C2816E44 if (1 === preg_match('@organiser/([^/]+)/status@', $response->getResource(), $matches)) { $reportId = $matches[1]; } else { throw new RuntimeException('Unable to extract report ID from response'); } return $reportId; }
/** * @see CultureFeed_Pages::updatePage() */ public function updatePage($id, array $params) { $result = $this->oauth_client->authenticatedPost('page/' . $id, $params); $xmlElement = $this->validateResult($result, CultureFeed_Pages_Default::PAGE_MODIFIED); return $xmlElement->xpath_str('uid'); }