Still don't working with Rules' actions

Antinoo - April 14, 2009 - 22:38
Project:Twitter
Version:6.x-2.3
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:active
Description

Using the Rules module, I've add a "Post to Twitter" action but the tokens (%node_url, %title, %teaser, and so on) are not replaced: on twitter.com, it's posted something like %title (%node_url).

Am I missing something?

#1

Antinoo - April 23, 2009 - 16:42

I've made some debug, but unfortunately I don't know exactly how actions (core action and rules actions) work.

Anyway, the problem is that when the twitter_actions_set_status_action() function is called, its first parameter, $object, is NULL.
This way, $node will be empty, and then $variables will not be merged with the %node_url, %title and so on variables.

Why is this happening?
I'm using the [Node] After saving new content event.

Is it because the Twitter action is not a Node action?

Any thought?

#2

Antinoo - April 23, 2009 - 16:57

Update. I've also created a new RuleSet with a "Content" argument and assigned it to the node created, but still doesn't work.

#3

Sebo - October 18, 2009 - 09:55

Hi, this issue still appears on 6.x-2.6, making the twitter action not very usefull (only the site name is replaced).

Any update or alternative to generate automated twitter posts including the node title and node url and using the Rules module?

Thanks!

#4

Sebo - November 11, 2009 - 12:40

Note that even if the %* variabled cannot be used, some php code can do the work instead.

For example, to output the node title and an url to the node in the twit (assuming you previously did a 'load content' action to load the node object, and provided a 'Machine readable variable name': $nd), write the following code in the 'Message' field of your 'Post a message to Twitter' action:

<?php
print $nd->title . ' ' . url('node/' . $nd->nid, array('absolute' => true));
?>

=> This enabled me using this great module for my use-case!

#5

lasac - November 12, 2009 - 15:19

Sebo,

Thanks for that fix!

I tweaked it a bit to make it work with pathalias so we dont see node/nid but the pathalias

<?php
$path
= 'node/' . $nd->nid;
print
url(drupal_get_path_alias($path), array('absolute' => true));
print
" - ".$nd->title;
?>

Above automaticaly converts to tinyurl =)

#6

lasac - November 12, 2009 - 15:14

Tweaked it even some more, to strip the HTML tags. I as admin post my nodes with html turned on. So to delete the html use:

<?php
$path
= 'node/' . $nd->nid;
print
url(drupal_get_path_alias($path), array('absolute' => true));
print
" - ".strip_tags( $nd->body );
?>

 
 

Drupal is a registered trademark of Dries Buytaert.