UNPKG

hellojs-xiaotian

Version:

A clientside Javascript library for standardizing requests to OAuth2 web services (and OAuth1 - with a shim)

61 lines (48 loc) 1.58 kB
<!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>