在Twitter Feed中过滤@replies? [英] Filter out @replies in a Twitter feed?

查看:125
本文介绍了在Twitter Feed中过滤@replies?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站顶部有一个Twitter个人资料供稿,但我想知道是否有办法过滤出我的@replies并只显示我的状态更新?



感谢

解决方案

如果您使用Blogger和类似网站的标准Twitter供稿网页代码,做的伎俩。它位于Twitter供稿和回调之间,并将回复从服务器响应中删除。

对于博客徽章,标准Twitter网页代码以两个< script> 标签结尾。第一个提供显示你的推文的功能。第二个查询推文以显示推文。

在twitter查询之前将此脚本添加到您的徽章代码中。它提供了一个名为filterCallback的新函数,它从Twitter响应中删除@replies。

 < script type =text / javascript> 
函数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; //编辑这个来改变显示的最大推文

twitterCallback2(result); //将推文传递到原始回调。不要改变!
}
< / script>

twitter查询本身有一个参数,它指定响应返回时要调用的函数。在博客的情况下,该函数被称为'twitterCallback2' - 你可以在网页代码中搜索它(查找 callback = twitterCallback2 )。要使用新过滤器,您需要使用 filterCallback 替换文本 twittercallback2 。过滤器被硬编码,然后在完成时调用 twitterCallback2

注意,这样会减少如果来自Twitter的某些回复是回复,则显示推文,因此您必须增加通话中的计数参数以允许这样做。然后,新功能将显示的回复数量限制为五个 - 编辑代码以更改该回复。



以下是我的博客文章:用Twitter Feed过滤回复


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

解决方案

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

这篇关于在Twitter Feed中过滤@replies?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆