-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhome.php
More file actions
159 lines (127 loc) · 5.67 KB
/
Copy pathhome.php
File metadata and controls
159 lines (127 loc) · 5.67 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php
session_start();
include ("connect.php");
$uid = $_SESSION['uid'];
$usr = mysql_query("select * from `YOUR_TABLE_NAME` where id=$uid");
$usr = mysql_fetch_array($usr);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Tutorial Demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link href="bootstrap/css/bootstrap.css" rel="stylesheet">
<link href="style.css" rel="stylesheet">
<link href="bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
function updateStatus(url, access_token, app_id){
document.getElementById('post_button').disabled = true;
message = document.getElementById('status').value;
var jqxhr = $.post(url, { "access_token": access_token, "message": message, "app_id": app_id },
function(data) {
alert("Status updated successfully!");
document.getElementById('post_button').disabled = false;
document.getElementById('status').value = "";
})
.success(function() { alert("second success"); })
.error(function(data, textStatus, jqXHR) {
if (data.status == 200){
alert("Status updated successfully!");
document.getElementById('post_button').disabled = false;
document.getElementById('status').value = "";
}
})
.complete(function() { });
}
function testDelete()
{
return confirm("Are you sure you want to delete your account?");
}
</script>
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="#">Tutorial Demo</a>
<div class="nav-collapse">
<ul class="nav">
<li><a href="index.php">Home</a></li>
<li class="active"><a href="home.php">My account</a></li>
<li><a href="http://aniri.ro/geek/tutorials/how-to-make-website-registration-easier-using-facebook-accounts">Read tutorial</a></li>
<li><a href="#">Feedback</a></li>
</ul>
</div>
</div>
</div>
</div>
<div class="container">
<div class="content">
<div class="page-header">
<h1>signup with facebook</h1>
</div>
<div class="row">
<div class="span8">
<div class="main">
<h3><?php echo $usr['username'];?>'s account</h4>
<?php
$graph_url = "https://graph.facebook.com/me/friends?access_token="
. $_SESSION['access_token'];
$friends = json_decode(file_get_contents($graph_url));
$friends_array = $friends->data;
$signedup = 0;
$ids_array = Array();
for($i = 0; $i < count($friends_array); $i++){
$ids_array[] = $friends_array[$i]->{'id'};
}
$q = mysql_query("select facebook_id from `YOUR_TABLE_NAME`");
while ($id = mysql_fetch_array($q)){
if (in_array($id['facebook_id'], $ids_array)){
$signedup += 1;
}
}
?>
<div class="alert alert-info" style="margin: 20px;">You have <?php echo count($friends_array);?> friends on facebook, <?php echo $signedup;?> have an account here!</div>
<div style="margin: 20px;">
<form id="fb_form">
<textarea rows="7" style="width: 98%" id="status" name="status"></textarea>
<br/>
<?php
$url = "https://graph.facebook.com/".$usr['facebook_id']."/feed";
$app_id = "YOUR_APP_ID";
$access_token = $_SESSION['access_token'];
?>
<button id="post_button" class="btn btn-primary" onclick="updateStatus('<?php echo $url;?>', '<?php echo $access_token;?>', '<?php echo $app_id;?>')">Post on facebook</button>
</form>
</div>
<div style="margin: 20px;">
<a onclick="return testDelete();" href="deleteAccount.php?id=<?php echo $usr[id];?>"><button class="btn btn-warning">Delete account</button></a>
<a href="logout.php"><button class="btn btn-inverse">Logout</button></a>
</div>
</div>
</div>
<div class="span4">
<h3>Instructions:</h3>
<div style="padding: 20px;">
This is a tutorial to show you how to sign up users to your application using their facebook account.
<br/><br/>
You can read the tutorial <a href="http://aniri.ro/geek/tutorials/how-to-make-website-registration-easier-using-facebook-accounts">here</a>.
<br/><br/>
On this page you can view some info about your facebook friends and update your status. Try it out!
</div>
</div>
</div>
</div>
<?php include "footer.php";?>
</div>
</body>
</html>