Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
218 lines (132 sloc) 5 KB
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Testeando</title>
</head>
<body>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/fb.script.js"></script>
<script type="text/javascript">
$(window).load(function(){
var face = $("#face").fb(function(){
if(this.isOn()){
$(".conectado").fadeIn();
mosPage();
$("#pubP").click(function(){
var pagId=$('#pags option:selected').val();
pubPage({pag_id:pagId,msg:$("#estado").val()});
});
}
else
$("#face").fadeIn();
$("body").append("<ul class='info' style='display:none'></ul>");
});
console.log(face);
});
function mosPage(){
    $('#container').show();
    FB.api(
    {
        method: 'fql.query',
        query: 'SELECT page_id,name from page WHERE page_id IN ( SELECT page_id from page_admin WHERE uid=me())'
    },
        function(resp) {
//cargamos las paginas del usuario en un select        
        html='';
        $.each(resp,function(key,val){
            html+='<option value="'+val.page_id+'">'+val.name+'</option>';
        });
        $('#pags').html(html);
     }
); 
 
}
function pubPage(args)
{
this.args = {
pag_id : "473941369312625",
msg : "Probando gomoFB",
link : "http://gomosoft.com",
picture : "http://gomosoft.com/img/logo.png",
callback:function(resp){
if (!resp || resp.error) {
             console.log('Ups! error');
               } else {
             console.log('Se ha publicado todo id: '+resp.id);
         }
}
};
if(args)
$.extend(this.args,args);
console.log(this.args);
    FB.api('/'+this.args.pag_id+'/feed', 'post',
    {
        message: this.args.msg,
        
    },this.args.callback);
}
function paginas(){
$(".info").html("");
fql("SELECT page_id, type from page_admin WHERE uid=me()",
function(resp){
for (x in resp){
console.log(resp[x].page_id);
pubPage({pag_id:resp[x].page_id});
fql("SELECT name, fan_count, pic_small FROM page WHERE page_id ="+resp[x].page_id,
function(res){
console.log(res[0])
res = res[0];
$(".info").append("<li> <img src='"+res.pic_small+"' />&nbsp; "+res.name+" &nbsp; "+res.fan_count+" likes</li>")
});
}
$(".info").fadeIn();
});
}
function estado(){
pubEstado("Probando gomo fb plugin ");
}
function graph(){
publicaGraph(function(resp){
console.log(resp);
alert("Todo se publicó correctamente");
});
}
function usuario(){
fbInfo(function(resp){
console.log(resp);
var info = $(".info")
info.html("");
info.append("<li>Foto de perfil: &nbsp;<img src='https://graph.facebook.com/"+resp.id+"/picture' alt='' /></li>");
info.append("<li>Nombre: "+resp.name+"</li>");
info.append("<li>Sexo: "+resp.gender+"</li>");
info.append("<li>email: "+resp.email+"</li>");
info.append("<li>ciudad de origen: "+resp.hometown.name+"</li>");
info.append("<li>Reside en: "+resp.location.name+"</li>");
info.append("<li>Idioma: "+resp.locale+"</li>");
fql("SELECT interests,friend_count,pic_cover FROM user where uid=me()", function(resp){
resp = resp[0];
console.log(resp);
info.append("<li>Amigos: "+resp.friend_count+"</li>");
info.append("<li>foto de portada: &nbsp; <img src='"+resp.pic_cover.source+"' alt='' /></li>");
});
info.fadeIn();
});
}
</script>
<h1>Plugin jQuery gomoFB</h1>
<button id="face" style="display:none"> Conectar </button> <br/>
<div class="conectado" style="display:none">
<button id="pub_est" onclick="graph()">Publicar en la biografia con Graph</button><br/>
<button id="pub_est" onclick="estado()">Publicar estado</button><br/>
<button id="pag" onclick="paginas()">Mostrar mis páginas</button><br/>
<button id="face" onclick="usuario()"> Mostrar mis datos </button> <br/>
</div>
<br />
<div id="container" style="display:none;">
<select id="pags"></select> <br />
<textarea id="estado"></textarea> <br />
<input type="button" value="Publicar en el muro de la pagina" id="pubP" />
</div>
</body>
</html>