Closed (fixed)
Project:
Twitter
Version:
7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
22 Feb 2009 at 04:10 UTC
Updated:
20 Dec 2012 at 23:20 UTC
Use case:
For Drupalchix, I want to pull in several users' Twitter feeds via Feed API and re-tweet them over a single account, so all nodes of a "tweet" type should be posted to Twitter.
It'd be convenient if there was an option to always post a particular content type to Twitter, rather than having to check a box. This is especially relevant because Feed API creates nodes through node_object_prepare() and node_save(), rather than drupal_execute(), so this code never gets fired.
In the meantime, here's a small hook_nodeapi() implementation that does this for someone who needs this functionality now.
/**
* Implementation of hook_nodeapi().
*/
function drupalchix_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
switch ($op) {
case 'insert':
if ($node->type == 'tweet') {
module_load_include('inc', 'twitter');
$twitter_accounts = drupal_map_assoc(array_keys(twitter_get_user_accounts($node->uid, TRUE)));
$node->twitter['post'] = TRUE;
$node->twitter['status'] = 'RT @!title';
$node->twitter['account'] = array_pop(array_keys($twitter_accounts));
}
break;
}
}
Comments
Comment #1
Leeteq commented+1
Comment #2
rudygodoy commented+1
Comment #3
summit commentedHi, where to add this in the twitter module? Is beneath code correct:
I have the same situation as feedapi but with another content type. Story and page nodes the "Post to twitter.com" is shown, but for example weblinks not.
greetings, Martijn
Comment #4
nancydruOut of curiosity, since Summit also posted a similar request to the Web Links queue, why can the Twitter module not correctly handle a standard node creation mechanism (node/add/mytype)?
Comment #5
raintonr commented+1
Our use case is that when a community member (user on the Drupal site) posts a new 'event' type on the Drupal site, that this is tweeted on an account that belongs to the site.
Eg. we have a twitter account 'Our organisation' that should have a list of tweets with links to all events.
Side issue: Moderators should optionally be able tweet any content on an account that belongs to the site, not their personal twitter. That appears OT for this issue though.
Comment #6
yngens commentedI'd like to use blog api with twitter module to tweet story type documents. Where exactly the code above should go into?
Comment #7
socialnicheguru commentedis this part of dev 3?
Is there a way to just set this on the content type page?
Comment #10
xurizaemonNo way to set this on the content page at this point.
Issue has languished for a long time, and there's a working solution above so will postpone until someone contributes a patch.
Comment #11
juampynr commentedClosing.
Comment #12
raintonr commentedWhile there may be code snippets in this thread that give a clue as to how this could be done, I do no see that warrants the issue being closed.
It is obviously a sought after feature and not all users are technical enough to implement code so re-opening.
Comment #13
juampynr commented@raintor, I think that you can achieve this with the twitter_actions submodule.
1. Enable twitter_actions
2. authenticate a Twitter account and make it global
3. Create a Rule that triggers when new content of type foo is created.
4. Set up a Post to Twitter reaction using the global account.
Let me know if this works for you.