my first post from my mac, just getting a hang around shortcuts and settings. I know diving into javascript will confuse my syntax with my current favourite python. so i decided to leave behind python and django and start javascript. This twitter api venture is to do some natural language processing on user tweets to obtain some knowledge cloud/graph. details not known at the moment!
twitter api v1 statuses/user_timeline
options and brief tutorial
user tweets:
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script>
function searchTwitter(query) {
$.ajax({
url: 'https://api.twitter.com/1/statuses/user_timeline.json?'+jQuery.param(query),
dataType: 'jsonp',
success: function(data) {
var tweets = $('#tweets');
tweets.html('');
for (res in data) {
tweets.append('<div>' + data[res]['created_at'] + ' wrote: <p>' + data[res]['text'] + '</p></div><br />');
}
}
});
}
$(document).ready(function() {
$('#submit').click(function() {
var params = {
screen_name: $('#query').val(),
count: $('#count').val()
};
searchTwitter(params);
});
});
</script>
</head>
<body>
<div style="padding: 20px;">
<input id="query" type="text" value="pmontu2" />
<input id="count" type="text" value="5" />
<input id="submit" type="button" value="Search" />
</div>
<div id="tweets" style="padding: 20px;">
Tweets will go here.
</div>
</body>
</html>
search:
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script>
function searchTwitter(query) {
$.ajax({
url: 'http://search.twitter.com/search.json?' + jQuery.param(query),
dataType: 'jsonp',
success: function(data) {
var tweets = $('#tweets');
tweets.html('');
for (res in data['results']) {
tweets.append('<div>' + data['results'][res]['from_user'] + ' wrote: <p>' + data['results'][res]['text'] + '</p></div><br />');
}
}
});
}
$(document).ready(function() {
$('#submit').click(function() {
var params = {
q: $('#query').val(),
rpp: 5
};
// alert(jQuery.param(params));
searchTwitter(params);
});
});
</script>
</head>
<body>
<div style="padding: 20px;">
<input id="query" type="text" value="blue angels" />
<input id="submit" type="button" value="Search" />
</div>
<div id="tweets" style="padding: 20px;">
Tweets will go here.
</div>
</body>
</html>

