0

我正在寻找一个小部件/jquery 插件/托管服务或类似服务,您可以将其放到一个 html 页面上,它会实时显示和更新包含某个主题标签的推文,但只能来自一个或多个可配置帐户 + 审核以批准其他人的推文具有相同的标签。

想想想要实时发布活动的报纸,但可以控制其他人在页面上显示的内容。

我已经搜索过,但没有找到任何合适的东西——我相信它一定存在。

4

1 回答 1

1

Hiya演示 http://jsfiddle.net/RGrgM/ http://jsfiddle.net/RGrgM/show/

我已将某人(我的)推文与此演示相关联,但您可以链接您的:)我在推特上很懒,anyhooo:P 这将对您有所帮助。它将与实时提要一起使用。

休息一切都在那里,您可以右键单击并查看源代码并阅读以下代码。B-)

这个 [链接] 可能会派上用场:http ://boxmodeljunkie.com/create-a-simple-twitter-widget-with-yui-3-and-yql/

:)

D'uh 不要忘记接受并投票!

它用:

  <title>Twitter Feed Widget with YUI 3 &amp; YQL - jsFiddle demo</title>

  <script type='text/javascript' src='/js/lib/yui-min-3.2.0.js'></script>

jQuery代码

// top-level global namespace
YUI.namespace('CIF');

// accepts a tweet timestamp and produces relational time text
YUI.CIF.relativeTime = function ( c ) {

    var origStamp = Date.parse( c ),

        curDate = new Date(),

        currentStamp = curDate.getTime(),

        difference = parseInt( ( currentStamp - origStamp ) / 1000, 10 ),

        dateArr = c.toString().split(' ');

    // if no difference, do nothing
    if ( difference < 0 ) {
        return false;
    }

    if ( difference <= 5 ) {
        return "Just now";
    }

    if ( difference <= 20 ) {
        return "Seconds ago";
    }

    if ( difference <= 60 ) {
        return "A minute ago";
    }

    if ( difference < 3600 ) {
        return parseInt( difference / 60, 10 ) + ' minutes ago';
    }

    if (difference <= 1.5 * 3600) {
        return "One hour ago";
    }

    if ( difference < 23.5 * 3600 ) {
        return Math.round( difference / 3600 ) + ' hours ago';
    }

    if (difference < 1.5*24*3600) {
        return "One day ago";
    }

    // produce date stamp for tweets older than a day
    return dateArr[3].replace( /\:\d+$/,'' ) + ' ' + dateArr[2] + ' ' + dateArr[1] + dateArr[5] !== curDate.getFullYear().toString() ? ' ' + dateArr[5] : '';

};

// load required modules and set up YUI instance
YUI().use( 'node', 'substitute', 'yql', function ( Y ) {

    var n = Y.one( '#twitterFeed' ),

        // accepts a YQL JSON result object and produces a list of 
        // tweets using Y.substitute for templating
        formatTwitterFeed = function ( r ) {

            if (r) {

                var s = r.query.results.statuses.status,

                    // HTML markup template
                    t = '<li><span class="status-text">{sText}</span> <span ' + 
                        'class="quiet status-time">{sTime}</span></li>',

                    l = s.length,

                    f = '<ul>',

                    i;

                for ( i = 0; i < l; i++ ) {

                    // Y.substitute method to merge HTML markup and result object
                    f += Y.substitute( t, {

                        // convert usernames, hash tags and URLs to links
                        sText : s[i].text
                            .replace(/(http\S+)/i,'<a href="$1" target="_blank">$1</a>')
                            .replace(/(@)([a-z0-9_\-]+)/i,
                                '<a href="http://twitter.com/$2" target="_blank">$1$2</a>')
                            .replace(/(#)(\S+)/ig, 
                                '<a href="http://search.twitter.com/search' + 
                                '?q=%23$2" target="_blank">$1$2</a>'),

                        sTime : YUI.CIF.relativeTime( s[i].created_at )

                    } );

                }

                f += '</ul>';

                f += '<a class="button" href="http://twitter.com/tats_innit" title="Follow @Tats_innit on Twitter" target="_blank">Follow on Twitter&nbsp;&raquo;</a>';

                // append output to target parent node
                n.append( f );

            }

        };

    // YQL Twitter query limited to five results for a specified username
    Y.YQL( 'select * from twitter.user.timeline( 5 ) ' + 
            'where screen_name="@tats_innit"', formatTwitterFeed );

});
​
于 2012-05-13T10:45:22.720 回答