forked from MrSwitch/hello.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tumblr.html
71 lines (59 loc) · 1.71 KB
/
tumblr.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
69
70
71
<!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/tumblr.js"></script>
<title>hello( tumblr )</title>
<h1>hello( tumblr )</h1>
<button id='login' onclick="login('tumblr');">Tumblr</button>
<div id="result"></div>
<script class="pre">
function login(network){
hello( network ).login().then( function(r){
// Get Profile
hello(network).api('me').then(function(p){
console.log(p);
document.getElementById('login').innerHTML = "Connected to "+ network+" as " + p.name;
});
}, function(e){
console.error(e);
});
}
hello.init({
'tumblr' : TUMBLR_CLIENT_ID
},
{
redirect_uri:'../redirect.html',
oauth_proxy: OAUTH_PROXY_URL
});
</script>
<h2>Custom functions search</h2>
<button onclick="getPosts('peacecorps.tumblr.com')">Get blog posts e.g. (from 'peacecorps.tumblr.com')</button>
<pre id="blogs" placeholder="warning this loads a lot of content"></pre>
<script class="pre">
function getPosts(blog){
hello('tumblr').api('blog/'+blog+'/posts/text?notes_info=true').then(function(r){
var a = r.data.map(function(item){
return "<h2>"+item.title+"</h2>"+item.body_abstract;
});
document.getElementById('blogs').innerHTML = a.join('');
});
}
</script>
<h2>GET me/like</h2>
<button onclick="likes('tumblr')">Get my likes</button>
<pre id="likes"></pre>
<script class="pre">
function likes(network){
hello( network ).login({force:false}).then( function(r){
// Get Profile
hello(network).api('me/like').then(function(p){
console.log(p);
});
}, function(e){
console.error(e);
});
}
</script>