tags:

views:

1223

answers:

5

I have a feed from my Twitter profile on the top of my site but I wondered if there is a way to filter out my @replies and only show my status updates?

Thanks

+6  A: 

Maybe with Yahoo Pipes.

Tomalak has made a quick example for you.

Node
This would be an easy way to do it.
OverloadUT
I've made a quick example: http://pipes.yahoo.com/tomalak/bbeckford_sample
Tomalak
Great, Yahoo pipes is impressive! Thanks!
bbeckford
Looks like that one's down. This works well: http://pipes.yahoo.com/pipes/pipe.info?_id=mgAGWe6_3RGl_C_tPxJ3AQ
bluej100
A: 

Depends on what you're using to display the entries. If you're using Twitter's widget, then probably not. If you're using some other programmatic way of displaying the items, you'd need to provide more details about what you're doing (language, sample code, etc) and we can probably help with filtering.

ahockley
A: 

You'll probably want to use a regular expression. Something along the lines of:

[a-zA-Z0-9][a-zA-Z0-9]*: @[a-zA-Z0-9][a-zA-Z0-9]*.*

Depending on how you are formatting your twitter feed on your page. This regex assumes that you're formatted something like:

username: @username msg txt

If it matches, don't display it. If it doesn't match, then display it. :) If you've got tags in there along with the text, adjust the regex appropriately.

Michael Trausch
+3  A: 

If you're using the standard Twitter feed web code for Blogger and similar sites, this bit of Javascript does the trick. It sits between the Twitter feed and the callback and strips replies out of the server response.

For a blog badge, the standard Twitter web code ends with two <script> tags. The first provides the function that displays your tweets. The second queries twitter for the tweets to display.

Add this script to your badge code before the twitter query. It provides a new function called filterCallback which strips @replies from the Twitter response.

<script type="text/javascript">
  function filterCallback( twitter_json ) {
    var result = [];
    for(var index in twitter_json) {
      if(twitter_json[index].in_reply_to_user_id == null) {
        result[result.length] = twitter_json[index];
      }
      if( result.length==5 ) break; // Edit this to change the maximum tweets shown
    }
    twitterCallback2(result); // Pass tweets onto the original callback. Don't change it!
  }
  </script>

The twitter query itself has a parameter which specifies what function to call when the response comes back. In blogger's case, that function is called 'twitterCallback2' - you can search for it in the web code (look for callback=twitterCallback2). To use the new filter you need to replace the text twittercallback2 with filterCallback. The filter is hard coded to then call twitterCallback2 when it's done.

Note that as this will reduce the number of displayed tweets if some of the repsonses from Twitter are replies, so you have to increase the count parameter in the call to allow for that. The new function then limits the number of displayed replies to five - edit the code to change that.

Here's my blog post about it: Filter Replies out of Twitter Feed

AndyT
Great, thanks a lot!
bbeckford
A: 

If you want to use the new Twitter widgets, just add this piece of code within the features: setting of the widget's source code:

filters: {
  negatives: /\B@\w{1,20}(\s+|$)/
},

I took this one from Dustin Diaz's website at http://www.dustindiaz.com. Dustin Diaz is the creator of the Twitter widget.

djeidot