Forked from nguyenphucbao68/GetTokenFullPermissionIOS.js
Created
November 17, 2018 02:55
-
-
Save minhphuc429/398fc4d39fce1529539024d359f341b1 to your computer and use it in GitHub Desktop.
Get Token Full Permission IO
This file contains hidden or 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
/* | |
* 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