You are here

private function TweetFeed::checkSpecificTweets in Tweet Feed 4.x

1 call to TweetFeed::checkSpecificTweets()
TweetFeed::saveTweet in src/Controller/TweetFeed.php
Save the tweet to our tweet entity.

File

src/Controller/TweetFeed.php, line 231

Class

TweetFeed
Class TweetFeed.

Namespace

Drupal\tweet_feed\Controller

Code

private function checkSpecificTweets($specific_tweets, $feed) {

  /** Get the account of the feed we are processing */
  $accounts_config = \Drupal::service('config.factory')
    ->get('tweet_feed.twitter_accounts');
  $accounts = $accounts_config
    ->get('accounts');
  if (!empty($accounts[$feed['aid']])) {
    $account = $accounts[$feed['aid']];
  }
  $tweet_count = 0;
  foreach ($specific_tweets as $tweet_id) {

    // Build TwitterOAuth object with client credentials
    $con = new TwitterOAuth2($account['consumer_key'], $account['consumer_secret'], $account['oauth_token'], $account['oauth_token_secret']);
    $tweet = $con
      ->get("statuses/show", [
      'id' => $tweet_id,
      'tweet_mode' => 'extended',
    ]);
    if (!empty($tweet->errors)) {
      continue;
    }
    else {
      $this
        ->saveTweet($tweet, $feed, TRUE);
      $tweet_count++;
    }
  }
  return $tweet_count;
}