I'm new to the Twitter module and perhaps this should be obvious, but how do you set up a rule to post a message to the current user's Twitter account? At the moment, the form in the "Post a message to Twitter" action only permits a static screen name at rule creation time. I want to use a token for the current user's Twitter account. If the user has more than one account, for the moment it's ok to use the first.
I tried adding a custom token that queries the current user's screen_name and comment out the form check on lines 68-70 in twitter_actions.module to allow it to be used as the Twitter account name, but that doesn't seem to be enough. Any ideas?
Custom token code:
$sql = "SELECT screen_name FROM {twitter_account} WHERE uid = %d";
$results = db_query($sql, $user->uid);
while ($row = db_fetch_array($results)) {
return($row[screen_name]);
}
Comments
Comment #1
escore CreditAttribution: escore commentedComment #2
Sizzly CreditAttribution: Sizzly commentedescore,
Your custom token code worked brilliantly for me (granted just at first stages of testing). Many thanks!
All I had to do was remove the PHP encapsulation (<?PHP ?>) for the code and it worked great.
Much appreciated.
Rob
Comment #3
13rac1 CreditAttribution: 13rac1 commentedSet #1191076: Bounty for "use token is twitter post user name as a duplicate of this.
Comment #4
juampynr CreditAttribution: juampynr commentedThis logic was present on 6.x-3.x and got lost during the upgrade to Drupal 7. I will see how can we get it back.
Comment #5
juampynr CreditAttribution: juampynr commentedAdded option [current user] at twitter_actions so modules Rules and Action can set it to use current user's Twitter account to post messages when available.
http://drupalcode.org/project/twitter.git/commitdiff/575faba
Comment #6
juampynr CreditAttribution: juampynr commentedBackported to 6.x-5.x.
http://drupalcode.org/project/twitter.git/commitdiff/5239df4