1) I have setup Twitter module and OAuth successfully, but there doesn't seem to be any way in the UI to retrieve the "mentions" for a particular user. Am I missing something?

2) I can pull them manually with code like:

$twitter_accounts = twitter_get_user_accounts(1); // uid
$account = $twitter_accounts[0];

$twitter = twitter_connect($account);

foreach ($twitter->mentions() as $status) {
  twitter_status_save($status);
}

And then create a view that lists these tweets - but then the profile-image (etc) are broken, because the view is left-joining to {twitter_account}, expecting the poster to have an entry there. A possible solution might be to create "dummy" accounts in twitter_account to represent tweets from people who aren't on the Drupal site, and possibly promote them to "real" accounts if they sign up on the site. Or is this missing the point of this module?

Comments

lyricnz’s picture

Naively, saving the twitter user seems to be as simple as

module_load_include('inc', 'twitter');

$twitter_accounts = twitter_get_user_accounts(1); // uid
$account = $twitter_accounts[0];

$twitter = twitter_connect($account);
foreach ($twitter->mentions() as $status) {
  $twitter_user = twitter_account_load($status->user->id);
  if ($twitter_user->id == NULL) {
    // save "dummy" user
    $twitter_user = $status->user;
    $twitter_user->import = FALSE;
    twitter_account_save($twitter_user);
  }
  twitter_status_save($status);
}
juampynr’s picture

Title: How to retrieve Twitter mentions? » Retrieve Twitter mentions
Version: 6.x-3.x-dev » 7.x-4.x-dev
Status: Active » Fixed

Added support for retrieving user mentions and a Views display to list all tweets.

http://drupalcode.org/project/twitter.git/commitdiff/d1b54ad

This will be backported to 6.x-4.x in the following days.

Status: Fixed » Closed (fixed)

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