-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathindex.php
More file actions
109 lines (95 loc) · 3.99 KB
/
index.php
File metadata and controls
109 lines (95 loc) · 3.99 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<html>
<head>
<script src="jquery-3.0.0.min.js"></script>
<script src="https://sdk.accountkit.com/en_US/sdk.js"></script>
<style>
body{
font-family: tahoma;
}
.message {
background-color: #222;
border: 1px solid #dcdcdc;
color: #fff;
font-family: tahoma;
margin-top: 84px;
min-height: 250px;
padding: 2px 45px;
text-align: left;
width: 50%;
word-wrap: break-word;
}
</style>
</head>
<body>
<div>
<center>
<h3>View the video demo in youtube <a href="https://youtu.be/o2-PCiiJzr4" target="_blank">https://youtu.be/o2-PCiiJzr4</a></h3>
<br>
<input value="+1" id="country_code" />
<input placeholder="phone number" id="phone_number"/>
<button onclick="smsLogin();">Login via SMS</button>
<div>OR</div>
<input placeholder="email" id="email"/>
<button onclick="emailLogin();">Login via Email</button>
<div class="message">
<p><center><b>Message Board</b></center></p>
</div>
</center>
</div>
<script>
//https://developers.facebook.com/docs/accountkit/webjs
$(".message").append("<p>initialized Account Kit.</p>");
// initialize Account Kit with CSRF protection
AccountKit_OnInteractive = function(){
AccountKit.init(
{
appId:"YOUR_FACEBOOK_APP_ID",
state:"CSRF_TOKEN",
version:"v1.0",
fbAppEventsEnabled:true
}
);
};
// login callback
function loginCallback(response) {
if (response.status === "PARTIALLY_AUTHENTICATED") {
var code = response.code;
var csrf = response.state;
$(".message").append("<p>Received auth token from facebook - "+ code +".</p>");
$(".message").append("<p>Triggering AJAX for server-side validation.</p>");
$.post("verify.php", { code : code, csrf : csrf }, function(result){
$(".message").append( "<p>Server response : " + result + "</p>" );
});
}
else if (response.status === "NOT_AUTHENTICATED") {
// handle authentication failure
$(".message").append("<p>( Error ) NOT_AUTHENTICATED status received from facebook, something went wrong.</p>");
}
else if (response.status === "BAD_PARAMS") {
// handle bad parameters
$(".message").append("<p>( Error ) BAD_PARAMS status received from facebook, something went wrong.</p>");
}
}
// phone form submission handler
function smsLogin() {
var countryCode = document.getElementById("country_code").value;
var phoneNumber = document.getElementById("phone_number").value;
$(".message").append("<p>Triggering phone validation.</p>");
AccountKit.login(
'PHONE',
{countryCode: countryCode, phoneNumber: phoneNumber}, // will use default values if not specified
loginCallback
);
}
// email form submission handler
function emailLogin() {
var emailAddress = document.getElementById("email").value;
AccountKit.login(
'EMAIL',
{emailAddress: emailAddress},
loginCallback
);
}
</script>
</body>
</html>