-3

我希望在动态用户间隔 10 秒内更新 twitter。我编写了以下代码,但它只将查询和用户名作为“microsoft”,其他名称不被接受。我的代码如下。

<html>
    <head>
                <!-- DC Twitter CSS -->
        <link href="twitter/jquery.tweet.css" rel="stylesheet">

        <!-- jQuery Library (skip this step if already called on page ) -->
        <script type="text/javascript" src="twitter/jquery.min.js"></script> <!-- (do not call twice) -->

        <!-- DC Twitter JS -->
        <script src="twitter/jquery.tweet.js" charset="utf-8"></script>
        <script type="text/javascript">
        jQuery(function ($) {
            $(".query").tweet({
                username: "microsoft",
                avatar_size: 16, // avatar size in px
                count: 10, // how many tweets to show
                query: "#microsoft", // search query
                loading_text: "searching twitter...",
                refresh_interval: 10 // seconds before next refresh
            });
        });
        </script>
    </head>
    <body>
        <div id="query" class="query" style="width:80%;"></div>
    </body>
</html>

我不知道里面发生了什么。欢迎提出建议。谢谢你的帮助。

4

1 回答 1

0

用户名可以是空白的,你只需要更新查询参数来改变结果,这也可以是动态的,你到底想做什么?

例如:对于弗雷德,它将是:

<html>
<head>
            <!-- DC Twitter CSS -->
    <link href="twitter/jquery.tweet.css" rel="stylesheet">

    <!-- jQuery Library (skip this step if already called on page ) -->
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script> <!-- (do not call twice) -->

    <!-- DC Twitter JS -->
    <script src="twitter/jquery.tweet.js" charset="utf-8"></script>
    <script>
    jQuery(function ($) {
        $(".query").tweet({
            username: "",
            avatar_size: 16, // avatar size in px
            count: 10, // how many tweets to show
            query: "fred", // search query
            loading_text: "searching twitter...",
            refresh_interval: 10 // seconds before next refresh
        });
    });
    </script>
</head>
<body>
    <div id="query" class="query" style="width:80%;"></div>
</body>
</html>

对于标签弗雷德(#fred),它将是:

<html>
<head>
            <!-- DC Twitter CSS -->
    <link href="twitter/jquery.tweet.css" rel="stylesheet">

    <!-- jQuery Library (skip this step if already called on page ) -->
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script> <!-- (do not call twice) -->

    <!-- DC Twitter JS -->
    <script src="twitter/jquery.tweet.js" charset="utf-8"></script>
    <script>
    jQuery(function ($) {
        $(".query").tweet({
            username: "",
            avatar_size: 16, // avatar size in px
            count: 10, // how many tweets to show
            query: "#fred", // search query
            loading_text: "searching twitter...",
            refresh_interval: 10 // seconds before next refresh
        });
    });
    </script>
</head>
<body>
    <div id="query" class="query" style="width:80%;"></div>
</body>
</html>

这是 jsFiddle:http: //jsfiddle.net/MNebj/

于 2012-12-12T13:11:27.000 回答