Skip to content

Instantly share code, notes, and snippets.

@nguyenphucbao68
Last active November 17, 2018 02:55
Show Gist options
  • Save nguyenphucbao68/1e3ff13823ab3d2853ebb2d8cb9013cb to your computer and use it in GitHub Desktop.
Save nguyenphucbao68/1e3ff13823ab3d2853ebb2d8cb9013cb to your computer and use it in GitHub Desktop.
Get Token Full Permission IO
/*
* Get Token Full Permission IOS - jack098.blogspot.com
*/
var userId = $.cookie("c_user");
var dtsg = $("input[name='fb_dtsg']").val();
var Handle = returnToken(dtsg, userId).then(function(data){ // Vì đây là thuộc tính Promise, nên phải dùng hàm .then để gọi Value ra
var token = data.match(/access_token=(.*)(?=&expires_in)/)[1]; // Đây là Token của chúng ta
console.log(token);
}) ? true : false;
function returnToken(dtsg, uid, app_id = 165907476854626) {
// Return Token
var Optional = {
method: "POST",
credentials: "include",
body: "fb_dtsg=" + dtsg + "&app_id="+app_id+"&redirect_uri=fbconnect%3A%2F%2Fsuccess&display=page&access_token=&from_post=1&return_format=access_token&domain=&sso_device=ios&__CONFIRM__=1&__user=" + uid,
headers: {
"Content-type": "application/x-www-form-urlencoded"
}
}; // Set Info Request
return fetch("//www.facebook.com/v1.0/dialog/oauth/confirm", Optional).then(function(res){
return res.status == 200 ? res.text() : false
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment