-
Notifications
You must be signed in to change notification settings - Fork 0
/
social_button.php
68 lines (58 loc) · 1.78 KB
/
social_button.php
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '344827722600977',
autoLogAppEvents : true,
xfbml : true,
version : 'v2.9'
});
FB.Event.subscribe('auth.statusChange', getFBUser);
FB.Event.subscribe('edge.create', function(response) {
// like clicked
alert(response);
console.log('like');
});
};
(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#xfbml=1&version=v2.9&appId=344827722600977";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function getFBUser(response) {
if(response.authResponse.userID != "undefined") {
renderLoginButton();
}
FB.api('/me', function(response) {
console.log(response);
//var img_link = "http://graph.facebook.com/"+response.id+"/picture"
});
}
function renderLoginButton() {
document.getElementById('controlls').innerHTML =`<div id="login_button" class="fb-login-button" data-max-rows="1" data-size="large" data-button-type="continue_with"
data-show-faces="false" data-auto-logout-link="false" data-use-continue-as="true"></div>`;
}
</script>
<div id="controlls"></div>
<script>
renderLoginButton();
</script>
<!-- Your like button code -->
<div class="fb-like"
data-href="<? echo 'http://'. $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; ?>"
data-layout="button_count"
data-action="like"
data-share="true"
data-show-faces="false">
</div>
</body>
</html>