Created
August 15, 2011 15:41
-
-
Save screeley/1147024 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en"> | |
<head><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> | |
<script type="text/javascript" src="http://scripts.embed.ly/jquery.embedly.js"></script></head> | |
<body> | |
<form action="" method="get"><input type="text" name="q"/><input type="submit" name="q" value="Search"/></form> | |
<ul></ul> | |
<script> | |
function searchTwitter(q){ | |
//Force twitter to only search image providers | |
q += " twitpic OR yfrog OR flic.kr OR tweetphoto OR twitgoo OR post.ly OR tumblr.com OR moby.to OR imgur filter:links" | |
$.ajax({url : "http://search.twitter.com/search.json?q="+escape(q)+"&rpp=20&callback=?", | |
success : function(data){ | |
$.each(data.results, function(index, obj){ | |
//Find a url in the status | |
var p = obj.text.match(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig); | |
if (p != null){ | |
var u = p[0].replace(' ', ''); | |
//Call Embedly | |
$.embedly(u, {maxWidth:500, key:'<your Embedly API key. Sign up at http://embed.ly/pricing>'}, function(oembed){ | |
//Make sure it's a photo and add it to the list. | |
if (oembed != null && oembed.type == "photo") | |
$("UL").append('<li>'+oembed.code+'</li>'); | |
}); | |
} | |
}); | |
}, | |
dataType: "json"}); | |
} | |
$(document).ready(function() { | |
$("form").bind("submit", function(e){e.preventDefault();$("UL").html('');searchTwitter($(this).children("INPUT[name=q]").val())});; | |
}); | |
</script></body></html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment