Skip to content

Instantly share code, notes, and snippets.

@bialikover
Created February 8, 2012 05:21
Show Gist options
  • Save bialikover/1765706 to your computer and use it in GitHub Desktop.
Save bialikover/1765706 to your computer and use it in GitHub Desktop.
siempre es jueves Completo... pero en raw
<html>
<head>
<title>Siempre es jueves</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
</head>
<body>
<div id="fb-root"></div>
<script>
var time = new Date();
window.fbAsyncInit = function() {
FB.init({
appId : '107677519315273',
status : true,
cookie : true,
xfbml : true,
oauth : true,
});
FB.login(function(response) {
if (response.authResponse) {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(user) {
if (user) {
var image = document.getElementById('image');
image.src = 'http://graph.facebook.com/' + user.id + '/picture';
var name = document.getElementById('name');
name.innerHTML = user.name
}
});
//este snippet trae los eventos de mis amigos benchmark: LIMIT 150 =>5.46s AND rsvp_status="attending" q1
FB.api("/fql",{q:
{'query0':'SELECT uid2 from friend WHERE uid1 = me() LIMIT 50',
'query1':'SELECT eid from event_member WHERE uid IN (SELECT uid2 FROM #query0)',
'query2':'SELECT eid, name, description, location, venue, start_time, end_time FROM event WHERE eid IN (SELECT eid FROM #query1)'
}},
function(response){
var events= response.data[2].fql_result_set;
for (var i = 0; events.length > i ; i++){
tstart = new Date(events[i].start_time * 1000);
tend = new Date(events[i].end_time * 1000);
if(time.toDateString() == tstart.toDateString()){
if(events[i].venue.latitude != null){
$("div#events").append("<p> id: "+events[i].eid+
" evento: "+events[i].name+
" latitud: "+events[i].venue.latitude+
" longitud: "+events[i].venue.longitude+
" empieza: "+tstart.toDateString()+
" termina: "+tend.toDateString()+"</p>");
}
}
else {console.log("no se encontraron eventos para hoy");}
}
}
);
} else {
console.log('User cancelled login or did not fully authorize.');
}
}, {scope: 'email'}
);
};
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
<div align="center">
<img id="image"/>
<div id="name"></div>
<div id="events"></div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment