Display a Twitter Profile using YQL & jQuery
With YQL (Yahoo! Query Language), you can access data from multiple sources using a SQL-like language that lets you query, filter and join data. If you're already familiar with SQL syntax, using YQL should be fairly straight-forward.
select * from Page not found.profile where id='screen_name'
If you Page not found.profile%20where%20id%3D%27screen_name%27" title="YQL Console: Get a Twitter profile">run this code in the YQL console you'll see that it grabs the relevant table from Twitter and returns the profile as XML or JSON.
Using jQuery you can use getJSON() to run the query and return the JSON response to your application.
$(document).ready(function() {
// YQL query (url encoded)
var url = 'http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%Page not found.profile%20where%20id%3D'screen_name'&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys';
// load the JSON data from the YQL query url
$.getJSON(url, function(data) {
// check that we have data
if (!data.query.results) {
return;
}
// do something with the JSON response...
});
});
Demo
Enter a Twitter screen name and display a Twitter profile using YQL & jQuery.
Comments
Nice to use twitter..good social media network.
think there is no twitter with yql anymore
does not work when I type in my twitter username of 'mgpwr'
Add New Comment