Commit 0676afa0 by agan

修改facebook登陆

parent 86099e9a
Showing with 95 additions and 91 deletions
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="UTF-8">
<script src="login.js"></script>
<title></title>
<meta charset="UTF-8">
<script src="login.js"></script>
</head>
<body>
<script>
function statusChangeCallback(response) { // Called with the results from FB.getLoginStatus().
console.log(response);
if (response.status === 'connected') { // Logged into your webpage and Facebook.
testAPI(response.authResponse.accessToken);
} else { // Not logged into your webpage or we are unable to tell.
if(url_get_params().error == undefined || url_get_params().code == undefined){
window.location.href = "https://www.facebook.com/v6.0/dialog/oauth?client_id=382456482257502&redirect_uri=https://www.footseen.com/footseen/login/index.html&state=045478b9202f7c4913ab5366eaf15f8a"
} else {
var obj = {
"cid":22,
<script>
function statusChangeCallback(response) { // Called with the results from FB.getLoginStatus().
console.log(response);
if (response.status === 'connected') { // Logged into your webpage and Facebook.
testAPI(response.authResponse.accessToken);
} else { // Not logged into your webpage or we are unable to tell.
if (url_get_params().error == undefined || url_get_params().code == undefined) {
window.location.href = "https://www.facebook.com/v6.0/dialog/oauth?client_id=382456482257502&redirect_uri=https://www.footseen.com/footseen/login/index.html&state=045478b9202f7c4913ab5366eaf15f8a"
} else {
var obj = {
"cid": 22,
"reqCode": new Date().getTime(),
"data": {
"msg":'facebook登录',
"type":2,
"id":"",
"name":"",
"url":"",
"token":""
}
"data": {
"msg": 'facebook登录',
"type": 2,
"id": "",
"name": "",
"url": "",
"token": ""
}
}
var obj2 = JSON.stringify(obj);
console.log(obj2);
appCollaboration(obj2)
}
}
}
function checkLoginState() { // Called when a person is finished with the Login Button.
FB.getLoginStatus(function(response) { // See the onlogin handler
statusChangeCallback(response);
});
}
window.fbAsyncInit = function() {
FB.init({
appId : '382456482257502',
xfbml : true,
cookie : true, // enable cookies to allow the server to access
version : 'v6.0'
});
FB.getLoginStatus(function(response) { // Called after the JS SDK has been initialized.
statusChangeCallback(response); // Returns the login status.
});
};
(function(d, s, id) { // Load the SDK asynchronously
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function testAPI(token) {
FB.api('/me?fields=email,name,id,picture.width(200).height(200)', function(response) {
console.log('登录成功');
var obj = {
"cid":22,
"reqCode": new Date().getTime(),
"data": {
"msg":'facebook登录',
"type":1,
"id":response.id,
"name":response.name,
"url":response.picture.data.url,
"token":token
}
}
}
}
function checkLoginState() { // Called when a person is finished with the Login Button.
FB.getLoginStatus(function (response) { // See the onlogin handler
statusChangeCallback(response);
});
}
window.fbAsyncInit = function () {
FB.init({
appId: '382456482257502',
xfbml: true,
cookie: true, // enable cookies to allow the server to access
version: 'v12.0'
});
FB.getLoginStatus(function (response) { // Called after the JS SDK has been initialized.
statusChangeCallback(response); // Returns the login status.
});
};
(function (d, s, id) { // Load the SDK asynchronously
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function testAPI(token) {
FB.api('/me?fields=email,name,id,picture.width(200).height(200)', function (response) {
console.log('登录成功');
var obj = {
"cid": 22,
"reqCode": new Date().getTime(),
"data": {
"msg": 'facebook登录',
"type": 1,
"id": response.id,
"name": response.name,
"url": response.picture.data.url,
"token": token
}
var obj2 = JSON.stringify(obj);
console.log(obj2);
appCollaboration(obj2)
});
}
function url_get_params() {
var url = location.href;
var theRequest = new Object();
if(url.indexOf("?") != -1) {
var str = url.substr(url.indexOf("?") + 1);
strs = str.split("&");
for(var i = 0; i < strs.length; i++) {
theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
}
var obj2 = JSON.stringify(obj);
console.log(obj2);
appCollaboration(obj2)
});
}
function url_get_params() {
var url = location.href;
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.substr(url.indexOf("?") + 1);
strs = str.split("&");
for (var i = 0; i < strs.length; i++) {
theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
}
}
return theRequest;
}
return theRequest;
}
</script>
</script>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment