-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathaddFBInfo.php
More file actions
65 lines (51 loc) · 1.68 KB
/
Copy pathaddFBInfo.php
File metadata and controls
65 lines (51 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
</head>
<body>
<script>
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
window.fbAsyncInit = function() {
FB.init({
appId : '411711342356748',
xfbml : true,
version : 'v2.5'
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function facebookInit(){
FB.api(
"/me?fields=first_name, last_name,id, email,birthday,gender",
function (response) {
if (response && !response.error) {
var date = new Date(response.birthday);
var d = date.getDate()
var m = date.getMonth() + 1;
var y = date.getFullYear();
var format_date = '' + y + '-' + (m<=9 ? '0' + m : m) + '-' + (d <= 9 ? '0' + d : d);
console.log(response.birthday);
window.location.replace("./fbMakeUser.php?firstname="+response.first_name+"&lastname="+response.last_name+"&birthday="+format_date+"&gender="+response.gender+"&email="+response.email+"&fbid="+response.id+"&username="+getUrlVars()["username"]);
}
}
);
}
$(function(){
facebookInit();
});
</script>
<p id ="Name"></p>
<button onclick="facebookInit()">Create Account</button>
</body>
</html>