Automate Twitter Posts from Submitted Content using Rules

Events happening in the community are now at Drupal community events on www.drupal.org.
twistedindustries's picture

I need help! I have fought with this for hours and have search everywhere with no luck. What I am trying to do I would of thought to be very simple, WRONG! I have a form that collects the users name (Title of node) and link (CCK text field) when the user submits a form of this content type I would like to generate a post to twitter with that information. That's it!

I have debug turned on and can verify that rules is running through the actions properly. I have a rule set with a variable. I am using load content by ID and can't seem to get it to grab the node id, it only works if I enter the id manually, which won't work.

I am a newbie and I am desperate for help! Thank you so much to anyone willing to help me!

Comments

Node id token ?

shushu's picture

Hi,
Although you described the situation, it still a bit hard to understand it.
From what I understand, you have a rule that should get the node id as an input. When you "manually" write it - it works, but when you try to "grab" it you fail.
Do you mean you use a token to get the node id ? If so, which token exactly, and what are the variables exist in the rule ?

Maybe exposting the rule and attaching it here can be useful for better help.

good luck,
shushu

ShuShu, Thank you for

twistedindustries's picture

ShuShu,

Thank you for responding I am somewhat of a newbie at all this. Despite my poor attempt at describing my problem I think you got the idea. Here is an example of my rule that doesn't work which I would think would be "grabbing" the node id, this just posts the tokens without replacing them:

array (
  'rules' =>
  array (
    'rules_10' =>
    array (
      '#type' => 'rule',
      '#set' => 'event_edit_yourself_node_form_form_submit',
      '#label' => 'Edit Yourself Redirect/Tweet',
      '#active' => 1,
      '#weight' => '0',
      '#categories' =>
      array (
      ),
      '#status' => 'custom',
      '#conditions' =>
      array (
      ),
      '#actions' =>
      array (
        0 =>
        array (
          '#weight' => 0,
          '#info' =>
          array (
            'label' => 'Load content by id',
            'arguments' =>
            array (
              'nid' =>
              array (
                'type' => 'number',
                'label' => 'Content ID',
              ),
              'vid' =>
              array (
                'type' => 'number',
                'label' => 'Content Revision ID',
                'description' => 'If you want to load a specific revision, specify it\'s revision id. Else leave it empty to load the current revision.',
                'required' => false,
              ),
            ),
            'new variables' =>
            array (
              'node_loaded' =>
              array (
                'label' => 'content with id [node:nid]',
                'label callback' => false,
                'type' => 'node',
              ),
            ),
            'module' => 'Node',
          ),
          '#name' => 'rules_action_load_node',
          '#settings' =>
          array (
            'nid' => '[node:nid]',
            'vid' => '',
            '#argument map' =>
            array (
              'node_loaded' => 'node_loaded',
            ),
          ),
          '#type' => 'action',
        ),
        1 =>
        array (
          '#type' => 'action',
          '#settings' =>
          array (
            '#argument map' =>
            array (
              'node' => 'node_loaded',
            ),
          ),
          '#name' => 'rules_action_invoke_set_rules_set_1',
          '#info' =>
          array (
            'label' => 'Post to Twitter Rule Set',
            'arguments' =>
            array (
              'node' =>
              array (
                'type' => 'node',
                'label' => 'Content',
              ),
            ),
            'categories' =>
            array (
              0 => 'example',
            ),
            'status' => 'custom',
            'module' => 'Rule Sets',
            'base' => 'rules_action_invoke_set',
            'set' => 'rules_set_1',
          ),
          '#weight' => 0,
        ),
      ),
      '#version' => 6003,
    ),
  ),
)

Here is an example that works but I have to manually enter a node id (50) for it I cannot use token replacement:

array (
  'rules' =>
  array (
    'rules_10' =>
    array (
      '#type' => 'rule',
      '#set' => 'event_edit_yourself_node_form_form_submit',
      '#label' => 'Edit Yourself Redirect/Tweet',
      '#active' => 1,
      '#weight' => '0',
      '#categories' =>
      array (
      ),
      '#status' => 'custom',
      '#conditions' =>
      array (
      ),
      '#actions' =>
      array (
        0 =>
        array (
          '#weight' => 0,
          '#type' => 'action',
          '#settings' =>
          array (
            'nid' => '50',
            'vid' => '',
            '#argument map' =>
            array (
              'node_loaded' => 'node_loaded',
            ),
          ),
          '#name' => 'rules_action_load_node',
          '#info' =>
          array (
            'label' => 'Load content by id',
            'arguments' =>
            array (
              'nid' =>
              array (
                'type' => 'number',
                'label' => 'Content ID',
              ),
              'vid' =>
              array (
                'type' => 'number',
                'label' => 'Content Revision ID',
                'description' => 'If you want to load a specific revision, specify it\'s revision id. Else leave it empty to load the current revision.',
                'required' => false,
              ),
            ),
            'new variables' =>
            array (
              'node_loaded' =>
              array (
                'label' => 'content with id 50',
                'label callback' => false,
                'type' => 'node',
              ),
            ),
            'module' => 'Node',
          ),
        ),
        1 =>
        array (
          '#weight' => 0,
          '#info' =>
          array (
            'label' => 'Post to Twitter Rule Set',
            'arguments' =>
            array (
              'node' =>
              array (
                'type' => 'node',
                'label' => 'Content',
              ),
            ),
            'categories' =>
            array (
              0 => 'example',
            ),
            'status' => 'custom',
            'module' => 'Rule Sets',
            'base' => 'rules_action_invoke_set',
            'set' => 'rules_set_1',
          ),
          '#name' => 'rules_action_invoke_set_rules_set_1',
          '#settings' =>
          array (
            '#argument map' =>
            array (
              'node' => 'node_loaded',
            ),
          ),
          '#type' => 'action',
        ),
      ),
      '#version' => 6003,
    ),
  ),
)

Rules

Group organizers

Group categories

Categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: