JSFiddle - React, Tailwind, and code Playground
HTML
<script src="//connect.facebook.net/en_US/all.js"></script>
<button id="create-event">Get events</button>
<button id="login">Login</button>
<button id="Send">Send</button>
<ul id="eventlist"></ul>
JavaScript
$('#create-event').click(function () {
FB.api("/me/events",function (response) {
if (response && !response.error) {
/* handle the result */
var events = response.data;
$.each(events,function(index){
$('ul').append('<li><a href="https://www.facebook.com/events/'+events[index].id+'">'+events[index].name+'</a><br/><span>Location : '+events[index].location+'</span><button class="tw">Share on twitter</button></li>');
});
}
else{
alert('Login to continue');
}
});
return false;
});
$('#login').click(function () {
FB.init({
appId: '227271484147869',
cookie: false, // enable cookies to allow the server to access // the session
xfbml: true, // parse social plugins on this page
status: false
});
fb_login();
});
$('#Send').click(function(){
console.log(FB.getAuthResponse(["accessToken"]) == undefined);
var url = 'http://rexona.newrepublique.com?query1=777&query2=6655';
FB.ui({
method: 'send',
link: url,
});
});
var accessToken;
function fb_login() {
FB.login(function (response) {
if (response.authResponse) {
// GetFbInfo(response.authResponse.accessToken);
checkLoginState();
//console.log(response.authResponse.accessToken);
} else {}
}, {
scope: 'publish_stream,email,user_events'
});
}
//FB.getLoginStatus(function (response) {
// statusChangeCallback(response);
//});
function checkLoginState() {
FB.getLoginStatus(function (response) {
statusChangeCallback(response);
});
}
function statusChangeCallback(response) {
//console.log('statusChangeCallback');
//console.log(response);
// The response object is returned with a status field that lets the
// app know the current login status of the person.
// for FB.getLoginStatus().
//callLoad();
if (response.status...