Skip to content

Instantly share code, notes, and snippets.

@taisang1996
Created November 15, 2016 10:02
Show Gist options
  • Save taisang1996/eaed4b690de79a705467e26caff6946d to your computer and use it in GitHub Desktop.
Save taisang1996/eaed4b690de79a705467e26caff6946d to your computer and use it in GitHub Desktop.
Lấy access token
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