Ryan
Ryan

Reputation: 69

Search button - Twitter Search API

I'm trying to create a button that takes a subject you've typed in and pulls the relevant tweets using the Twitter Search API.

I've seen something similar with the jTwitter plugin, but I'm not sure on how to do it myself, and can't seem to find any documentation on it.

Here's the jQuery:

twitterUrl = "http://search.twitter.com/search.json?"+ q +"&rpp=1500&page=2&result_type=recent&callback=?";
       twitterList = $( "<ul />" );
       twitterFunction = function( data ) {
             $.each( data.results, function( i, item ) {
                   $( "<li />", { "text" : item.text } )
                        .appendTo( twitterList );
                   });
             $( "#twit" ).fadeOut( "fast", function(){
                   $( this ).empty()
                        .append( twitterList )
                        .fadeIn( "slow" );            
                   });
             };
$.getJSON( twitterUrl, twitterFunction );

And the HTML:

<article>
        <form>
            <input type="text" id="subject" name="q" placeholder="subject..." >
            <input type="button" id="start" value="start" >
        </form>
        <div id="twit"></div>
</article>

And a working jsFiddle.

Thanks for your help.

Upvotes: 0

Views: 305

Answers (2)

Jayendra
Jayendra

Reputation: 52799

Check the implementation @ http://jsfiddle.net/Jayendra/reVy7/10/

Customize the results handling.

Upvotes: 1

xkeshav
xkeshav

Reputation: 54050

I'll suggest you to use jQuery Twitter Search Plugin

Upvotes: 0

Related Questions