public function OAuthHTTPFetcherResult::getRaw in Feeds OAuth 7
Implementation of FeedsImportBatch::getRaw().
Overrides FeedsFetcherResult::getRaw
File
- ./
OAuthHTTPFetcher.inc, line 39 - Definition of the import batch object created on the fetching stage by OAuthHTTPFetcher.
Class
- OAuthHTTPFetcherResult
- @file Definition of the import batch object created on the fetching stage by OAuthHTTPFetcher.
Code
public function getRaw() {
// Get access token.
$access_token = call_user_func($this->authenticator, $this->uid, $this->site_id, $this->id);
if (empty($access_token)) {
watchdog('feeds_oauth', 'Authenticator %authenticator returned empty access token for uid %uid, site %site. Aborting.', array(
'%authenticator' => $this->authenticator,
'%uid' => $this->uid,
'%site' => $this->site_id,
), WATCHDOG_WARNING);
return array();
}
// Instantiate OAuth client.
$path = variable_get('feeds_oauth_library_path', FEEDS_OAUTH_LIBRARY_PATH_DEFAULT);
if ($this->two) {
require_once $path . '/lib/oauth/OAuth2Client.php';
$oauth = new proauth\OAuth2CurlClient(new proauth\OAuth2AccessToken($access_token['oauth_token']));
}
else {
require_once $path . '/lib/oauth/OAuthClient.php';
$oauth = new proauth\OAuthCurlClient(new proauth\OAuthConsumer($this->consumer_key, $this->consumer_secret), new proauth\OAuthSignatureHMACSHA1(), new proauth\OAuthToken($access_token['oauth_token'], $access_token['oauth_token_secret']));
}
// Make the call.
$parsed_url = parse_url($this->url);
$query = array();
if (!empty($parsed_url['query'])) {
parse_str($parsed_url['query'], $query);
}
if ($this->two) {
$query += array(
'access_token' => $oauth
->getAccessToken()
->getToken(),
);
}
try {
if ($this->method == 'post') {
$request = $oauth
->createPostRequest($this->url, $query);
}
else {
$request = $oauth
->createGetRequest($this->url, $query);
}
$response = $oauth
->executeRequest($request);
if ($response
->getStatusCode() == 200) {
return $response
->getBody();
}
else {
watchdog('feeds_oauth', print_r($response
->getBody(), TRUE), array(), WATCHDOG_ERROR);
}
} catch (Exception $e) {
watchdog('feeds_oauth', $e
->getMessage(), array(), WATCHDOG_ERROR);
}
return array();
}