/
index.html
218 lines (132 loc) · 5 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<!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+"' /> "+res.name+" "+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: <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: <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>