-
Notifications
You must be signed in to change notification settings - Fork 0
/
with_pagination.html
executable file
·114 lines (104 loc) · 2.82 KB
/
with_pagination.html
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
<DOCTYPE html>
<html lang="en">
<head>
<script>
</script>
<title>Super Fans</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- <link rel="stylesheet" href="./css/bootstrap.min.css">
//<link rel="stylesheet" href="./css/normalize.css">
// <script src="./js/jquery.min.js"></script>
// <script src="./js/bootstrap.min.js"></script>*/-->
</head>
<body >
<div id="fb-root"></div>
<script>
var count = 0;
function statusChangeCallback(response) {
if (response.status === 'connected') {
// window.location = "./result.html";
testAPI("/me/albums?fields=id");
} else if (response.status === 'not_authorized') {
document.getElementById('status').innerHTML = '<br><blockquote>Login to check who likes your Pictures most.</blockquote>';
} else {
document.getElementById('status').innerHTML = 'Please log ' +'into Facebook.';
}
}
function checkLoginState() {
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
}
window.fbAsyncInit = function() {
FB.init({
appId : '411454985723973',
cookie : true, // enable cookies to allow the server to access
// the session
status : true,
kidDirectedSite: false,
xfbml : true, // parse social plugins on this page
version : 'v2.4' // use version 2.2
});
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
};
// Load the SDK asynchronously
(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 testAPI(url) {
FB.api(url, function(response) {
var total_photos=0,i;
var count = 0;
var no_of_albums = response.data.length;
for(i=0;i<no_of_albums;i++)
{
var alb_url = "/"+response.data[i].id+"/"+"photos"+"?"+"limit="+100;
paging_photos(alb_url,total_photos,function(response){
count ++;
total_photos+=response;
if(count == no_of_albums)
{
console.log(total_photos);
}
});
}
});
}
function paging_photos(url1,sing,callback)
{
FB.api(url1,function(response)
{
sing = sing + response.data.length ;
if (response.paging && response.paging.next) {
// setTimeout(function() {paging_photos(response.paging.next,sing)},1000);
paging_photos(response.paging.next,sing,callback);
}
else
{
// console.log("finale"+sing);
callback(sing);
}
});
}
</script>
<script>
</script>
<div class="container-fluid" id="start">
<div class="row" align="center">
<div class="col-md-12">
<fb:login-button scope="public_profile,email,user_photos" onlogin="checkLoginState();">
</fb:login-button>
<div id="status">
</div>
</div><!--col-sm-4 -->
</div><!-- row -->
</div>
</body>
</html>