I want to have it so that I can have a node field/term, 'hashtag', in a node type which then is used to grab tweets from a feed with the hashtags attached as taxonomy terms and the user as a field.

a twitter search feed is semantic:http://search.twitter.com/search.atom?q=%23exampleHashtag

so I should be able to append a taxonomy field with a vocabulary of hashtags by printing it within the feed url, I just dont know how to extract a field from the node on the page / node in database to add the feed to the api with hashtags as taxonomy terms, once this is achieved it should be fairly simple to create a views block with the taxonomy argument that matches hashtag vocabularies.

I'll donate $10 if the person who details the entire process wishes me to do so.

Comments

alex_b’s picture

Status: Active » Fixed

This is actually a Drupal site building task that you can do today with Feeds and a little bit of glue code in a custom module. I'll set this to fixed because there is nothing actionable for Feeds itself.

whatsnewsisyphus’s picture

That's why it was a support request, I was hoping that someone that works with such applications could give me a pointer in the right direction

whatsnewsisyphus’s picture

Status: Fixed » Active

Sorry but the documentation is too complex for a non coder so I have to ask here:

I want to run a programmatic operation to attach a feed to a node, if the node contains a cck_hashtag field and doesnt have a feed attached. the feed url being http://twitter.com/#search?q=%23exampleHashtag
I dont know how to write this operation code

I am assuming I can hard code the operation into the node type tpl file.

In parsing,
where would this go? this replaces hashtags and usernames as links in the title string

  function twitterify($ret) {
    $ret = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t< ]*)#", "\\1<a href=\"\\2\">\\2</a>", $ret);
    $ret = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r< ]*)#", "\\1<a href=\"http://\\2\">\\2</a>", $ret);
    $ret = preg_replace("/@(\w+)/", "<a href=\"http://www.twitter.com/\\1\">@\\1</a>", $ret);
    $ret = preg_replace("/#(\w+)/", "<a href=\"http://search.twitter.com/search?q=\\1\">#\\1</a>", $ret);
    return $ret;
  }

I can then display these in a views block with the node reference argument

guusbosman’s picture

whatsnewsisyphus, here's an answer to the second part of your question: "Where would this go?"

Rather than creating a plug-in to the Feeds module you could use the hook_nodeapi, as follows:

1. Create a new module, let's say twitterfeedparser
2. Write something like this:

function twitterfeedparser_nodeapi(&$node, $op) {
  switch ($op) {
    case 'presave':
      if ($node->type == 'feed_item') {
        $node->title = twitterify($node->title);
        $node->body = twitterify($node->body);
      }
      break;
   }
}
whatsnewsisyphus’s picture

so would that hook to the api and basically act as the parser before saving as long as it's enabled?

guusbosman’s picture

That's right.

Since it hooks in the API it will kick in no matter how the Feed Item is created -- through the Feeds module or manually (node/add/feed-item).

If you plan to create or edit Feed Items manually, you may want to add an additional if-statement to make sure that your twitterify methods only kick in the first time, not on subsequent edits.

I use something very similar to your twitterify methods on my personal site. You can see it here: http://www.guusbosman.nl (http://www.guusbosman.nl/node/4966 is an example without the extra parsing, since Friday tweets will show up like this: http://www.guusbosman.nl/node/4973). I'm still tweaking my parsing/formatting code.

alex_b’s picture

Status: Active » Fixed

Closing after prolonged period of inactivity.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

ipwa’s picture

I don't want to comment on a closed thread, but a quick way to do this is using the Twitter Pull module.

When you use 'twitter_pull_render' on your node template you can use the title or any cck fields as the tweetkey.

http://drupal.org/project/twitter_pull