forked from MrSwitch/hello.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfacebook.html
61 lines (48 loc) · 1.54 KB
/
facebook.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
<!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/facebook.js"></script>
<title>hello( facebook )</title>
<h1>hello( facebook )</h1>
<h2>Get profile</h2>
<button id='profile' onclick="login('facebook');">facebook</button>
<script class="pre">
function login(network) {
var facebook = hello(network);
facebook.login().then(function() {
// get user profile data
return facebook.api('me');
}).then(function(p) {
document.getElementById('profile').innerHTML = "<img src='"+ p.thumbnail + "' width=24/>Connected to "+ network +" as " + p.name;
});
}
</script>
<script class="pre">
hello.init({
facebook: FACEBOOK_CLIENT_ID
}, {
redirect_uri: '../redirect.html',
oauth_proxy: OAUTH_PROXY_URL
});
</script>
<h2>Get session permissions</h2>
<p>Obtain the list of permissions for the current session.</p>
<button onclick="getPermissions()">Get Permissions</button>
<script class="pre">
function getPermissions() {
var facebook = hello('facebook');
facebook.login({scope: 'friends'}).then(function() {
return facebook.api('me/permissions');
}).then(log.bind(null, 'permissions'));
}
</script>
<pre id="permissions"></pre>
<script>
function log(id, res){
var text = document.createTextNode(JSON.stringify(res, null, 2));
document.getElementById(id).appendChild(text);
}
</script>