class OAuthHTTPFetcher in Feeds OAuth 6
Same name and namespace in other branches
- 7 OAuthHTTPFetcher.inc \OAuthHTTPFetcher
Support OAuth authentication.
Hierarchy
- class \FeedsConfigurable
- class \FeedsPlugin implements FeedsSourceInterface
- class \FeedsFetcher
- class \FeedsHTTPFetcher
- class \OAuthHTTPFetcher
- class \FeedsHTTPFetcher
- class \FeedsFetcher
- class \FeedsPlugin implements FeedsSourceInterface
Expanded class hierarchy of OAuthHTTPFetcher
1 string reference to 'OAuthHTTPFetcher'
- feeds_oauth_feeds_plugins in ./
feeds_oauth.module - Implementation of hook_feed_plugins().
File
- ./
OAuthHTTPFetcher.inc, line 45
View source
class OAuthHTTPFetcher extends FeedsHTTPFetcher {
/**
* Use signed URL to fetch content.
*/
public function fetch(FeedsSource $source) {
$source_config = $source
->getConfigFor($this);
$source_node = node_load($source->feed_nid);
global $user;
return new OAuthHTTPBatch(trim($source_config['source']), $this->config['authenticator'], $this->config['consumer_key'], $this->config['consumer_secret'], $this->config['site_id'], $source_node ? $source_node->uid : $user->uid);
}
/**
* Declare defaults.
*/
public function configDefaults() {
return array(
'authenticator' => 'feeds_oauth_get_tokens',
'site_id' => '',
'consumer_key' => '',
'consumer_secret' => '',
'request_token_url' => '',
'access_token_url' => '',
'authorize_url' => '',
) + parent::configDefaults();
}
/**
* Add form options.
*/
public function configForm(&$form_state) {
$form = parent::configForm($form_state);
$form['use_pubsubhubbub'] = array(
'#type' => 'value',
'#value' => FALSE,
);
$form['authenticator'] = array(
'#type' => 'select',
'#title' => t('OAuth authenticator'),
'#default_value' => $this->config['authenticator'],
'#options' => module_invoke_all('feeds_oauth_authenticator'),
'#description' => t('Choose the authentication module that provides the needed OAuth tokens.'),
);
$form['site_id'] = array(
'#type' => 'textfield',
'#title' => t('Site identifier'),
'#default_value' => $this->config['site_id'],
'#description' => t('Internal identifier for this connection. Callback URL on OAuth server should be suffixed with this identifier.
For the current configuration, callback URL will be: <code>%url</code>', array(
'%url' => url('feeds/oauth/callback/' . $this->config['site_id'], array(
'absolute' => TRUE,
)),
)),
'#required' => TRUE,
);
$form['consumer_key'] = array(
'#type' => 'textfield',
'#title' => t('Consumer key'),
'#default_value' => $this->config['consumer_key'],
'#required' => TRUE,
);
$form['consumer_secret'] = array(
'#type' => 'textfield',
'#title' => t('Consumer secret'),
'#default_value' => $this->config['consumer_secret'],
'#required' => TRUE,
);
$form['request_token_url'] = array(
'#type' => 'textfield',
'#title' => t('Request token URL'),
'#default_value' => $this->config['request_token_url'],
'#required' => TRUE,
);
$form['access_token_url'] = array(
'#type' => 'textfield',
'#title' => t('Access token URL'),
'#default_value' => $this->config['access_token_url'],
'#required' => TRUE,
);
$form['authorize_url'] = array(
'#type' => 'textfield',
'#title' => t('Authorize URL'),
'#default_value' => $this->config['authorize_url'],
'#required' => TRUE,
);
return $form;
}
/**
* Expose source form.
*/
public function sourceForm($source_config) {
$form = parent::sourceForm($source_config);
global $user;
$access_tokens = call_user_func($this->config['authenticator'], $user->uid, $this->config['site_id']);
if (empty($access_tokens) && !empty($this->config['site_id'])) {
drupal_set_message(t('Could not find OAuth access tokens for site %site. You should probably <a href="@url">authenticate first</a> to access protected information.', array(
'%site' => $this->config['site_id'],
'@url' => url('feeds/oauth/authenticate/' . $this->id),
)), 'warning', FALSE);
}
return $form;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FeedsConfigurable:: |
protected | property | ||
FeedsConfigurable:: |
protected | property | CTools export enabled status of this object. | |
FeedsConfigurable:: |
protected | property | ||
FeedsConfigurable:: |
protected | property | ||
FeedsConfigurable:: |
public | function | Similar to setConfig but adds to existing configuration. | 1 |
FeedsConfigurable:: |
public | function | Submission handler for configForm(). | 3 |
FeedsConfigurable:: |
public | function | Validation handler for configForm(). | 3 |
FeedsConfigurable:: |
public | function | Copy a configuration. | 1 |
FeedsConfigurable:: |
public | function | Determine whether this object is persistent and enabled. I. e. it is defined either in code or in the database and it is enabled. | 1 |
FeedsConfigurable:: |
public | function | Implementation of getConfig(). | 1 |
FeedsConfigurable:: |
public static | function | Instantiate a FeedsConfigurable object. | 1 |
FeedsConfigurable:: |
public | function | Set configuration. | 1 |
FeedsConfigurable:: |
public | function | Override magic method __get(). Make sure that $this->config goes through getConfig() | |
FeedsConfigurable:: |
public | function | Override magic method __isset(). This is needed due to overriding __get(). | |
FeedsFetcher:: |
public | function | Menu item definition for fetchers of this class. Note how the path component in the item definition matches the return value of FeedsFetcher::path(); | |
FeedsFetcher:: |
public | function | Construct a path for a concrete fetcher/source combination. The result of this method matches up with the general path definition in FeedsFetcher::menuItem(). For example usage look at FeedsHTTPFetcher. | |
FeedsHTTPFetcher:: |
public | function |
Clear caches. Overrides FeedsFetcher:: |
|
FeedsHTTPFetcher:: |
public | function |
Implement FeedsFetcher::importPeriod(). Overrides FeedsFetcher:: |
|
FeedsHTTPFetcher:: |
public | function |
Implements FeedsFetcher::request(). Overrides FeedsFetcher:: |
|
FeedsHTTPFetcher:: |
public | function |
Override sourceDelete() - unsubscribe from hub. Overrides FeedsPlugin:: |
|
FeedsHTTPFetcher:: |
public | function |
Override parent::sourceFormValidate(). Overrides FeedsPlugin:: |
|
FeedsHTTPFetcher:: |
public | function |
Override sourceSave() - subscribe to hub. Overrides FeedsPlugin:: |
|
FeedsHTTPFetcher:: |
public | function |
Implement FeedsFetcher::subscribe() - subscribe to hub. Overrides FeedsFetcher:: |
|
FeedsHTTPFetcher:: |
protected | function | Convenience method for instantiating a subscriber object. | |
FeedsHTTPFetcher:: |
public | function |
Implement FeedsFetcher::unsubscribe() - unsubscribe from hub. Overrides FeedsFetcher:: |
|
FeedsPlugin:: |
public | function |
Returns TRUE if $this->sourceForm() returns a form. Overrides FeedsSourceInterface:: |
|
FeedsPlugin:: |
protected static | function | Loads on-behalf implementations from mappers/ directory. | |
FeedsPlugin:: |
public | function |
Save changes to the configuration of this object.
Delegate saving to parent (= Feed) which will collect
information from this object by way of getConfig() and store it. Overrides FeedsConfigurable:: |
|
FeedsPlugin:: |
public | function |
Implementation of FeedsSourceInterface::sourceDefaults(). Overrides FeedsSourceInterface:: |
1 |
FeedsPlugin:: |
protected | function |
Constructor. Overrides FeedsConfigurable:: |
|
OAuthHTTPFetcher:: |
public | function |
Declare defaults. Overrides FeedsHTTPFetcher:: |
|
OAuthHTTPFetcher:: |
public | function |
Add form options. Overrides FeedsHTTPFetcher:: |
|
OAuthHTTPFetcher:: |
public | function |
Use signed URL to fetch content. Overrides FeedsHTTPFetcher:: |
|
OAuthHTTPFetcher:: |
public | function |
Expose source form. Overrides FeedsHTTPFetcher:: |