Created
November 15, 2016 10:02
-
-
Save taisang1996/eaed4b690de79a705467e26caff6946d to your computer and use it in GitHub Desktop.
Lấy access token
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var url = "https://www.facebook.com/v1.0/dialog/oauth/confirm"; | |
var data = 'fb_dtsg=' + document['getElementsByName']('fb_dtsg')[0]['value'] + '&app_id=165907476854626&redirect_uri=fbconnect://success&display=popup&access_token=&sdk=&from_post=1&private=&tos=&login=&read=&write=&extended=&social_confirm=&confirm=&seen_scopes=&auth_type=&auth_token=&auth_nonce=&default_audience=&ref=Default&return_format=access_token&domain=&sso_device=ios&__CONFIRM__=1'; | |
var access_token = ""; | |
var xhr = new XMLHttpRequest; | |
xhr.open('POST', url, true); | |
xhr.onreadystatechange = function() { | |
if (xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) { | |
access_token = xhr.responseText.match(/token=(.+)&/)[1]; | |
// đã lấy dc access token | |
console.log(access_token); | |
} | |
} | |
xhr.send(data); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment