Kingsley eLearning Solutions

You have big dreams for your eLearning.
We'll make them come true.

image of Kingsley

Drupal, blogapi, Twitter, PixelPipe &Android

Submitted by Kingsley on Wed, 09/30/2009 - 16:31

I like all the items mentioned in the title.
I use the drupal twitter module to send tweets when I add content to my site. I use pixelpipe to send content to my site from my android phone via drupal's blogapi module.
Unfortunatly the blogapi module does not trigger the twitter module.
One work around is using the actions/trigger module but that doesnt pipe the URL though tinyurl first.
Here is my solution.
I altered the twitter_actions.module so that it automagicly converts the url (using existing code)
Then I disabled twitter posting in settings/twitter since my trigger/action will send a tweet for me.
I modified/add code starting around line 160:

// Node-based variable translation is only available if we have a node.
if (isset($node) && is_object($node)) {
$variables = array_merge($variables, array(
'%uid' => $node->uid,
'%node_url' => twitter_actions_shorten_url(url('node/'. $node->nid, array('absolute' => TRUE))),
'%node_type' => node_get_types('name', $node),
'%title' => $node->title,
'%teaser' => $node->teaser,
'%body' => $node->body
$message = strtr($context['message'], $variables);
module_load_include('inc', 'twitter');
twitter_set_status($context['screen_name'], $context['password'], $message);
* Very lightweight helper function to generate a TinyURL for a given post.
function twitter_actions_shorten_url($url) {
if (module_exists('shorten')) {
return shorten_url($url);
else {
$response = drupal_http_request("" . $url);
if ($response->code == 200) {
return $response->data;
else {
return $url;


Add new comment

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.

Enter the characters shown in the image.