You are here

class OAuth2HTTPSBatch in Feeds OAuth 6

Definition of the import batch object created on the fetching stage by OAuth2HTTPSFetcher.

Hierarchy

Expanded class hierarchy of OAuth2HTTPSBatch

File

./OAuth2HTTPSFetcher.inc, line 7

View source
class OAuth2HTTPSBatch extends FeedsImportBatch {
  protected $url;
  protected $authenticator;
  protected $consumer_key;
  protected $consumer_secret;
  protected $site_id;
  protected $uid;

  /**
   * Constructor.
   */
  public function __construct($url, $authenticator, $consumer_key, $consumer_secret, $site_id, $uid) {
    $this->url = $url;
    $this->authenticator = $authenticator;
    $this->consumer_key = $consumer_key;
    $this->consumer_secret = $consumer_secret;
    $this->site_id = $site_id;
    $this->uid = $uid;
    parent::__construct();
  }

  /**
   * Implementation of FeedsImportBatch::getRaw();
   */
  public function getRaw() {
    require_once drupal_get_path('module', 'feeds_oauth') . '/php-proauth-read-only/lib/oauth/OAuth2Client.php';
    $access_token = call_user_func($this->authenticator, $this->uid, $this->site_id);
    $oauth = new OAuth2CurlClient();
    $oauth
      ->_setAccessToken(new OAuth2AccessToken($access_token['oauth_token']));
    $request = $oauth
      ->createGetRequest($this->url, array(
      'access_token' => $oauth
        ->getAccessToken()
        ->getToken(),
    ));
    $response = $oauth
      ->executeRequest($request);
    if ($response
      ->getStatusCode() == 200) {
      return $response
        ->getBody();
    }
    else {
      watchdog('feeds_oauth', print_r($response
        ->getBody(), TRUE), array());
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FeedsBatch::$progress protected property
FeedsBatch::$total protected property
FeedsBatch::getProgress public function Report progress.
FeedsBatch::getTotal public function Get the total for a stage.
FeedsBatch::setProgress public function Set progress for a stage.
FeedsBatch::setTotal public function Set the total for a stage.
FeedsImportBatch::$created public property
FeedsImportBatch::$current_item protected property
FeedsImportBatch::$description public property
FeedsImportBatch::$feed_nid public property
FeedsImportBatch::$items public property
FeedsImportBatch::$link public property
FeedsImportBatch::$raw protected property
FeedsImportBatch::$title public property
FeedsImportBatch::$updated public property
FeedsImportBatch::addItem Deprecated public function Add an item.
FeedsImportBatch::currentItem public function
FeedsImportBatch::feedNode Deprecated public function
FeedsImportBatch::getDescription Deprecated public function
FeedsImportBatch::getFilePath public function 1
FeedsImportBatch::getItemCount Deprecated public function Get number of items.
FeedsImportBatch::getLink Deprecated public function
FeedsImportBatch::getTitle Deprecated public function
FeedsImportBatch::setDescription Deprecated public function Set description.
FeedsImportBatch::setItems Deprecated public function Set items.
FeedsImportBatch::setLink Deprecated public function Set link.
FeedsImportBatch::setTitle Deprecated public function Set title.
FeedsImportBatch::shiftItem public function @todo Move to a nextItem() based approach, not consuming the item array. Can only be done once we don't cache the entire batch object between page loads for batching anymore.
OAuth2HTTPSBatch::$authenticator protected property
OAuth2HTTPSBatch::$consumer_key protected property
OAuth2HTTPSBatch::$consumer_secret protected property
OAuth2HTTPSBatch::$site_id protected property
OAuth2HTTPSBatch::$uid protected property
OAuth2HTTPSBatch::$url protected property
OAuth2HTTPSBatch::getRaw public function Implementation of FeedsImportBatch::getRaw(); Overrides FeedsImportBatch::getRaw
OAuth2HTTPSBatch::__construct public function Constructor. Overrides FeedsImportBatch::__construct