Download & Extend

Still don't working with Rules' actions

Project:Twitter
Version:6.x-2.3
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed (duplicate)

Issue Summary

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?

Comments

#1

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

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

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

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

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

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 );
?>

#7

Just in case someone else stumbles on this thread, I was able to get some things to work here:

http://drupal.org/node/484030#comment-2772492

DC

#8

I added the php code from #6 but in this case no twitter action will be triggered at all. probably this is because i have not done "(assuming you previously did a 'load content' action to load the node object, and provided a 'Machine readable variable name': $nd)" can somebody explain this in more detail? i do not see these options as actions in the rule setup UI. thanks! :)

this way works for me: http://drupal.org/node/484030#comment-2998610

#9

Status:active» closed (duplicate)

There is work in progress splitting the code into a separate module #1317196: Implement Actions and Rules integration for Drupal 7. Pls. subscribe and help out testing the issue.

nobody click here