forked from MrSwitch/hello.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
twitter.html
68 lines (57 loc) · 1.46 KB
/
twitter.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
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE html>
<link rel="stylesheet" href="/adorn/adorn.css"/>
<script src="/adorn/adorn.js" async></script>
<script src="client_ids.js"></script>
<script src="../src/hello.polyfill.js"></script>
<script src="../src/hello.js"></script>
<script src="../src/modules/twitter.js"></script>
<title>hello( twitter )</title>
<h1>hello( twitter )</h1>
<button id='login' onclick="login('twitter');">Twitter</button>
<div id="result"></div>
<script class="pre">
function login(network){
// Twitter instance
var twitter = hello(network);
// Login
twitter.login().then( function(r){
// Get Profile
return twitter.api('me');
}, log )
.then( function(p){
// Put in page
document.getElementById('login').innerHTML = "<img src='"+ p.thumbnail + "' width=24/>Connected to "+ network+" as " + p.name;
}, log );
}
</script>
<script class="pre">
hello.init({
'twitter' : TWITTER_CLIENT_ID
},
{
redirect_uri:'../redirect.html',
oauth_proxy: OAUTH_PROXY_URL
});
</script>
<h2>Tweet</h2>
<form>
<label>message</label><textarea id="message"></textarea>
<br />
<label>media</label><input type="file" id="file"/>
</form>
<script class="pre">
function tweet(){
var message = document.getElementById('message').value;
var files = document.getElementById('file').files;
hello('twitter').api('me/share', 'POST', {
message : message,
file : file
}).then(log,log);
}
</script>
<button onclick="tweet()">Tweet</button>
<script>
function log(){
console.log(arguments);
}
</script>