We updated to Twitter 5.9 and all Twitter Pulls broke giving us 3 errors:

Could not retrieve data from Twitter. Forbidden
Twitter Pull is using an Unauthenticated request to twitter apis. Download, enable and configure the twitter module to allow for authenticated requests.
There are no authenticated Twitter accounts to use for API connections.

Once we reverted back to Twitter 5.8 all Twitter Pulls came back with no errors.

So I think it is safe to say something has changed in the new release causing Twitter Pull to fail? Any advice?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

glynster created an issue. See original summary.

glynster’s picture

Title: Twitter 5.9 modules incompatible with Twitter Pull » Twitter 5.9 module incompatible with Twitter Pull
stevensunsunsun’s picture

Same issue.

Twitter 5.9 caused Twitter Pull Authentication to fail.

Reverting to 5.8 fixed this.

kaosagnt’s picture

Yep many APIs have changed. This is the one killing Twitter Pull.

--- a/cgi-bin/XXX_XXX/sites/all/modules/twitter/twitter.inc
+++ b/cgi-bin/XXX_XXX/sites/all/modules/twitter/twitter.inc
@@ -10,28 +10,47 @@
/**
* Connect to the Twitter API.
*
- * @param object $account
+ * @param object $twitter_account
* An authenticated twitter_account object to be used to authenticate against
* Twitter.
+ * @param bool $access_global
+ * Whether or not to load the global accounts too.
+ * @param bool $force
+ * Loads accounts regardless of other access limits. Should be used with care
+ * and only for limited scenarios that do would not pose a security risk.
+ *
* @return
- * a Twitter object ready to be used to query the Twitter API or FALSE.
+ * A Twitter object ready to be used to query the Twitter API or FALSE.
*/
-function twitter_connect($account = NULL) {
- if (!$account) {
- // Load the first authenticated account.
- $twitter_uid = db_query("SELECT twitter_uid
- FROM {twitter_account}
- WHERE oauth_token <> ''
- AND oauth_token_secret <> '' ")->fetchField();
- $account = twitter_account_load($twitter_uid);
- }
- if ($account) {
- $auth = $account->get_auth();
- if (isset($auth['oauth_token']) && isset($auth['oauth_token_secret'])) {
- return new Twitter(variable_get('twitter_consumer_key', ''), variable_get('twitter_consumer_secret', ''),
- $auth['oauth_token'], $auth['oauth_token_secret']);
+function twitter_connect($twitter_account = NULL, $access_global = FALSE, $force = FALSE) {
+ // If no account was specified, load the first authenticated account.
+ if (empty($twitter_account)) {
+ // Load all authenticated accounts, passing in the same access requirements.
+ $accounts = twitter_load_authenticated_accounts(NULL, $access_global, $force);
+
+ // If no accounts were found, there's a problem.
+ if (empty($accounts)) {
+ watchdog('twitter', 'There are no authenticated Twitter accounts to use for API connections.');
+ }
+
+ // Grab the first authenticated account.
+ else {
+ $twitter_account = reset($accounts);
}
}
+
+ if (!empty($twitter_account)) {
+ $auth = $twitter_account->get_auth();
+ if (isset($auth['oauth_token']) && isset($auth['oauth_token_secret'])) {
+ return new Twitter(
+ variable_get('twitter_consumer_key', ''),
+ variable_get('twitter_consumer_secret', ''),
+ $auth['oauth_token'],
+ $auth['oauth_token_secret']
+ );
+ }
+ }
+
return FALSE;
}

For now I've change my twitter pull twitter_pull.class.inc

- $twitter = twitter_connect();
+ $twitter = twitter_connect(NULL, TRUE);

and made the twitter account global. We only have one account pulling tweets and don't have any other twitter functionality enabled.

glynster’s picture

I applied your small change and this did not work for me. I still receive the same 3 errors.

jesss’s picture

@kaosagnt's change in #4 worked for me. I'm also only using one account to pull tweets and no other Twitter functionality.

To clarify the steps:

1) Edit line 171 of twitter_pull.class.inc from:

$twitter = twitter_connect();

to

$twitter = twitter_connect(NULL, TRUE);

2) Go to admin/config/services/twitter and check the "Global" option for the account that you want to pull.

glynster’s picture

Awesome that worked a treat. I missed the global trick! Thank you so much for the help.

Beezer75’s picture

I just ran into the same problem, #6 fixed it for me. Thank you all for posting this!

kalabro’s picture

Status: Active » Needs review
FileSize
1.78 KB

Attached patch fixes Twitter Pull for me. It will work for Twitter Key setting "@twitter_name" without Global option. For other cases (like "#drupal") you still need at least one global account.

martins.bertins’s picture

#9 patch worked for me. Thanks!

glynster’s picture

#9 patch also worked for me!! +1 to have this committed.

milodesc’s picture

#9 seems to be working for me as well, and I'm using the 5.10 version of the twitter module.

Thanks for the patch.

kenorb’s picture

Status: Needs review » Reviewed & tested by the community

Applied patch, Twitter now works fine.

glynster’s picture

Removed.

achap’s picture

The patch in #9 works for me. +1 to have this committed.

jennypanighetti’s picture

+1 for committing please. Thanks!

agileadam’s picture

Patch in #9 worked perfectly for me as well.

hey_germano’s picture

Working for us, too. Thanks!

e.ryan.schmidt@gmail.com’s picture

I've been trying to figure this out for a few days -- #6 worked like a charm. Cheers!

dbazuin’s picture

The patch from comment #9 works for me.
looks like it is RTBC.

  • joachim committed 528ff1e on 7.x-2.x authored by kalabro
    Issue #2562681 by kalabro: Updated for compatibility with Twitter module...
joachim’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.