-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
83 lines (78 loc) · 2.16 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<title>Páginas Facebook</title>
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css">
<meta charset="utf-8">
</head>
<body>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '1223079081166440',
xfbml : true,
version : 'v3.0'
});
FB.getLoginStatus(function(response) { //para saber o status do usuário
statusChangeCallback(response);
});
};
(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 = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function statusChangeCallback(response){
if(response.status === 'connected'){
console.log("Usuário Autorizado");
requestAPI();
}else{
console.log("Não Autorizado");
}
}
function checkLoginState() {
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
}
function requestAPI(){
FB.api('me?fields=id,name,likes.limit(6){picture,fan_count,link,name}', function(response){
if(response){
console.log(response);
percorrepagina(response);
}
});
}
function percorrepagina(pagina){
paginas = document.getElementById('paginas');
paginas.innerHTML = '';
for(var i = 0; i < pagina.likes.data.length; i++){
paginas.innerHTML += `
<div class="card card-body bg-light">
<div class="media">
<div class="media-left">
<a href="#" style='padding:10px'>
<img class="media-object" src="${pagina.likes.data[i].picture.data.url}" alt="...">
</a>
</div>
<div class="media-body">
<h4 class="media-heading">${pagina.likes.data[i].name}</h4>
<p>
Cutidas <span class="badge">${pagina.likes.data[i].fan_count}</span>
</p>
</div>
</div>
<div>
` ;
}
}
</script>
<fb:login-button scope="public_profile,email, user_likes" onlogin="checkLoginState();">
</fb:login-button>
<div class="container">
<div id="paginas"></div>
</div>
</body>
</html>