ReviewMyElearning.com

Drupal, blogapi, Twitter, PixelPipe &Android

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("http://tinyurl.com/api-create.php?url=" . $url);
if ($response->code == 200) {
return $response->data;
}
else {
return $url;
}
}
}

Comments

It is not true suffering ennobles the character; happiness does that sometimes, but suffering, for the most part, makes men petty and vindictive.

ThanKSz

thank you for your sharing.

I have a mytouch phone and I love it! Great phone...

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • Images can be added to this post.
  • You may use [inline:xx] tags to display uploaded files or images inline.
  • You may use <swf file="song.mp3"> to display Flash files inline
  • Twitter-style @usersnames are linked to their Twitter account pages.
  • Twitter-style #hashtags are linked to search.twitter.com.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
  _  _  _  _            _  _  _                                   _  _        _           _    
(_)(_)(_)(_) _ _ (_)(_)(_) _ _(_)(_) (_)_ _(_)
(_) (_) (_) (_) _ _ _ (_) _ (_)_ _(_)
(_) _ _ _ (_) (_) (_)_ _(_) (_)(_)(_) (_)_(_)
(_)(_)(_)(_) (_) (_)_ _(_) (_) _(_)_
(_) (_) _ (_) _ (_)_ _(_) (_) _(_) (_)_
(_) (_) _ (_) _ _ _ (_) (_)_(_) (_) _(_) (_)_
(_) (_) (_)(_)(_) _(_) (_) (_) (_)
_ _(_)
(_)(_)
Enter the code depicted in ASCII art style.