-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathonetweet.html
58 lines (44 loc) · 1.4 KB
/
onetweet.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-migrate-1.1.0.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/3.17.2/build/yui/yui-min.js"></script>
<script src="js/twitterLogin.js"></script>
</head>
<body>
Get and display one tweet.
<div id="twitterlogin">Login</div>
<div style="clear:both;" id="userinfo"></div>
<script>
var xhr = new XMLHttpRequest();
xhr.open('post',"https://stream.twitter.com/1.1/statuses/filter.json");
xhr.setRequestHeader("Content-type","application/json");
// Track the state changes of the request.
xhr.onreadystatechange = function(){
// Ready state 4 means the request is done.
console.log('readyState',xhr.readyState);
if(xhr.readyState === 4){
if(xhr.status === 202){
console.log('SUCCESS',xhr.responseText);
}else{
console.log('FAILURE',xhr);
}
}
}
//BEGIN MY STUFF
console.log('BEGIN MY STUFF');
mySubmission = {
track: "barack obama"
};
console.log('send()');
xhr.send(JSON.stringify(mySubmission));
//END MY STUFF
//You have access to user id, name, screenname, description, etc.
//For more info visit https://dev.twitter.com/docs/api/1.1/get/account/verify_credentials
});
});
}
}); // yui.use();
</script>
</body>
</html>