-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.html
513 lines (465 loc) · 15.8 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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
<!doctype html>
<html lang="en">
<head>
<title>Facebook API for Hackathons</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=1024" />
<link href="css/basic-styles.css" rel="stylesheet" />
<link href="css/slide.css" rel="stylesheet" />
<link href='http://fonts.googleapis.com/css?family=Cabin+Condensed:400,700' rel='stylesheet' type='text/css'>
<link rel="shortcut icon" href="favicon.ico" />
</head>
<body>
<script>
// To use this demo on your own, you should change these values.
var settings = {
APP_ID : '410001752413776',
EVENT_ID : '314881508624057'
};
</script>
<img src="images/loading.gif" class="preload" />
<!-- This contains all the slides -->
<div id="impress">
<!-- (1) intro slide -->
<div
id="intro"
class="step"
data-x="1000"
data-y="0"
data-scale="2.5"
data-transition-duration="200">
<h1>facebook api</h1>
<h2>ways to bootstrap your hack</h2>
<div class="arrow_box"></div>
<!-- Lu's profile -->
<div class="profile">
<img src="https://graph.facebook.com/luchen/picture?width=200&height=200" />
<div class="table">
<div class="table-cell-valign">
<p><a href="http://www.fb.me/luchen">Lu Chen</a> (DMD '11)</p>
<p>Software Engineer on Timeline & Platform</p>
</div>
</div>
</div>
<!-- Ryan's profile -->
<div class="profile">
<img src="https://graph.facebook.com/ryandm/picture?width=200&height=200" />
<div class="table">
<div class="table-cell-valign">
<p><a href="http://www.fb.me/ryandm">Ryan Menezes</a> (CIS '11)</p>
<p>Software Engineer on Messages Infrastructure</p>
</div>
</div>
</div>
<p class="fact light center">
fun fact: we both participated in PennApps while at Penn and won
third place for our app "Decider"
</p>
</div>
<!-- (2) integration summary -->
<div
id="integration"
class="step"
data-x="6000"
data-y="0"
data-scale="5"
data-transition-duration="200">
<h1 class="center">what might help my hack?</h1>
<h2 class="center">let's go over a few tools at your disposal...</h2>
</div>
<!-- (3) fb login -->
<div
id="fb-login"
class="step"
data-x="8000"
data-y="-1200"
data-rotate="20"
data-scale="2.5"
data-transition-duration="200">
<h1 class="center">facebook login</h1>
<p class="center">
Don't waste precious hack time by writing
<br />
a login system from scratch.
</p>
</div>
<!-- (4) supported sdks -->
<div
id="supported-sdk"
class="step"
data-x="8750"
data-y="-2500"
data-rotate="110"
data-scale="2.3"
data-transition-duration="200">
<h1 class="center">
We have libraries for nearly all platforms and languages, making it
easy to use Facebook (and FB Login) within your app.
</h1>
<div class="icons">
<a href="https://developers.facebook.com/android/">
<img src="images/android.png" title="Android"/>
</a>
<a href="https://developers.facebook.com/ios/">
<img src="images/ios.png" title="iOS" />
</a>
<a href="https://developers.facebook.com/docs/howtos/login/login-for-desktop/">
<img src="images/desktop.png" title="Desktop Apps" />
</a>
<br />
<a href="https://developers.facebook.com/docs/reference/php/">
<img src="images/php.png" title="PHP SDK" />
</a>
<a href="https://developers.facebook.com/tools/third-party-sdks/">
<img src="images/python.png" title="Python" />
</a>
<a href="https://developers.facebook.com/tools/third-party-sdks/">
<img src="images/ruby.png" title="Ruby" />
</a>
<a href="https://developers.facebook.com/tools/third-party-sdks/">
<img src="images/node.png" title="Node.js" />
</a>
</div>
<p class="center">
We're using the
<a href="https://developers.facebook.com/docs/reference/javascript/" class="accent-yellow-light">
Javascript SDK
</a>
in this presentation.
</p>
</div>
<!-- (5) login demo. Search for 'fb_login_demo_js' below to look at the JS -->
<div
id="login-example"
class="step"
data-x="7650"
data-y="-2900"
data-scale="0.6"
data-rotate="110"
data-transition-duration="200">
<!-- what to show when logged out -->
<div id="login-demo-logged-out">
<h1>Logged Out View</h1>
<p>
Show the FB Login button, since the user isn't logged in.
</p>
<div class="fb-login-button" data-scope="user_events,user_actions.music">
</div>
</div>
<!-- what to show when logged in -->
<div id="login-demo-logged-in">
<h1>Logged In View</h1>
<p>
The user is logged in! You can immediately access the current
user's ID and profile pic. Your app can save this ID to your
backend to identify returning users.
</p>
<div class="dynamic-info clearfix">
<img id="profilePic" />
<input type="text" id="uniqueUserId" value="not connected" />
</div>
<p>
Uninstall the app to log out:
<a href="http://www.facebook.com/editapps.php">
App Settings
</a>
</p>
</div>
</div>
<!-- (6) graph splash -->
<div
id="graph"
class="step"
data-x="5250"
data-y="1700"
data-scale="4"
data-rotate="-20"
data-transition-duration="200">
<h1 class="center">the "graph"</h1>
<p>
Why create fake data to put in your app when you can use the real
stuff instead?
</p>
<p class="smaller">
<span class="accent-yellow-light">Read from the graph:</span>
newsfeed, check-ins, photos, music listens, messages, events, liked movies/books/sports, friends (and more)
</p>
<p class="smaller">
<span class="accent-yellow-light">Write to the graph:</span>
make status updates, upload photos and videos, add a check-in, create events (and more)
</p>
</div>
<!-- (7) event attendee demo -->
<div
id="event-attendees"
class="step"
data-x="8250"
data-y="1300"
data-rotate="-30"
data-scale="3"
data-transition-duration="200">
<div class="table">
<div class="node table-cell-valign">
<p>
Demo:
<strong>Attendees of the FB event</strong>
</p>
<pre>FB.api(
'<b>/<script>document.write(settings.EVENT_ID)</script>?fields=attending.fields(picture,name)</b>',
function(<b>response</b>) {
/* Here's where you handle the response.
* Be sure user_events is in your access token!
* To inspect this call in the API explorer <a onclick="goAPIExplorerEvent(); return false;" href="#">click here</a>.
*/
}
);</pre>
<input
type="button"
onclick="fillAttendeesOfEvent();"
value="Run API Call"
/>
<div id="event-attendees-results" class="results"></div>
<script>
var goAPIExplorerEvent = function() {
var url = 'https://developers.facebook.com/tools/explorer/?method=GET&path=' + settings.EVENT_ID +
'%3Ffields%3Dattending.fields(picture%2Cname)';
window.location.href = url;
};
var returnIsErrorAndAlertIfNeeded = function(response) {
var isError = !response || response.error;
if (isError)
alert('FB.api failed, must be demoitis :( You installed the app, right?');
return isError;
};
var appendImg = function(elem, src) {
$(elem).append($("<img>").attr({'src': src, 'width': 50}));
};
var fillAttendeesOfEvent = function() {
/* You can find out the id of any event by loading all the user's events.
I found the event ID id by going to:
https://developers.facebook.com/tools/explorer?method=GET&path=me%2Fevents
!!! make sure you add user_events to your access token !!!
*/
$('#event-attendees-results').html('').addClass('loading');
FB.api('/' + settings.EVENT_ID + '?fields=attending.fields(picture,name)', function(response) {
if (returnIsErrorAndAlertIfNeeded(response))
return;
var results = $('#event-attendees-results').html('').removeClass('loading');
var attendees = response.attending.data;
var numAdded = 0;
for (var i = 0; numAdded < 60 && i < attendees.length; i++) {
var person = attendees[i];
var picture_data = person.picture.data;
if (picture_data.is_silhouette) {
continue;
}
numAdded++;
appendImg(results, picture_data.url);
}
});
};
</script>
</div>
</div>
</div>
<!-- (8) music listens demo -->
<div
id="music-listens"
class="step"
data-x="6650"
data-y="3725"
data-scale="3"
data-transition-duration="200">
<div class="table">
<div class="node table-cell-valign">
<p>
Demo:
<strong>Recent Music Listens</strong>
</p>
<pre>FB.api(
'<b>/me/music.listens</b>',
function(<b>response</b>) {
/* Here's where you handle the response.
* Be sure user_actions.music is in your access token!
* To inspect this call in the API explorer <a href="https://developers.facebook.com/tools/explorer?method=GET&path=me%2Fmusic.listens" target="_blank">click here</a>.
*/
}
);</pre>
<input
type="button"
onclick="fillMusicListens();"
value="Run API Call"
/>
<div id='music-listens-results' class="results"></div>
<script>
var fillMusicListens = function() {
$('#music-listens-results').html('').addClass('loading');
FB.api('/me/music.listens', function(response) {
if (returnIsErrorAndAlertIfNeeded(response))
return;
var results = $('#music-listens-results').html('').removeClass('loading');
for (var i = 0; i < response.data.length && i < 22; i++) {
FB.api('/' + response.data[i].data.song.id, function(response) {
if (response && response.image && response.image[0] && response.image[0].url)
appendImg(results, response.image[0].url);
});
}
});
};
</script>
</div>
</div>
</div>
<!-- (9) facebook plugins -->
<div
id="plugins"
class="step"
data-x="3900"
data-y="-1200"
data-scale="3"
data-transition-duration="200">
<div class="caption fl">
<h1>plugins</h1>
<h2>copy and paste widgets for easy interaction</h2>
<h2 class="live">
this is live btw, not a screenshot.<br />
go on and add a comment →
</h2>
</div>
<div
class="fb-comments fr"
data-href="http://ldvchen.github.com/fbapidemo"
data-width="470"
data-num-posts="3"
data-order-by="reverse_time">
</div>
</div>
<!-- (10) fb notifications api -->
<div
id="notifs"
class="step"
data-x="3900"
data-y="-2500"
data-scale="3"
data-transition-duration="200">
<h1 class="center">notifications</h1>
<h2 class="center">
alert users via Facebook notifications
<span class="accent-yellow-light">just don't spam plz</span>
</h2>
<img src="images/notif.png" title="Notification screenshot" />
</div>
<!-- (11) summary -->
<div
id="summary"
class="step"
data-x="-6000"
data-y="2500"
data-scale="12"
data-transition-duration="200">
<h1>tl;dr</h1>
<p>
<a href="https://developers.facebook.com/docs/concepts/login/">
<b class="accent-yellow">Facebook Login</b>
</a>
= quickly & easily rig up a login system
</p>
<p>
<a href="https://developers.facebook.com/docs/reference/api/">
<b class="accent-yellow">Graph API</b>
</a>
= get real data (judges can actually try your app!)
</p>
<p>
<b class="accent-yellow">
<a href="https://developers.facebook.com/docs/howtos/notifications-api/">
Notifications
</a>
+
<a href="https://developers.facebook.com/docs/plugins/">
Plugins
</a>
</b>
= other ways to leverage Facebook
</p>
<h2>p.s.</h2>
<p>
FB is sponsoring a
<a href="http://2013s.pennapps.com/prizes/">
<b class="accent-yellow">$500 prize for "Best Social Integration"</b>
</a>
</p>
</div>
</div>
<!-- floating bar at the top -->
<div id="follow-along">
Live demo at
<a href="http://git.to/fbdemo">
<b class="accent-yellow">git.to/fbdemo</b>
</a>
—
Source code at
<a href="http://git.to/demosource">
<b class="accent-yellow">git.to/demosource</b>
</a>
</div>
<!-- include the impress.js and jQuery libraryes -->
<script src="impress.js/js/impress.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script>impress().init();</script>
<!-- Facebook API integration with Javascript API -->
<div id="fb-root"></div>
<script class="fb_login_demo_js">
// Update the page state based on if the user is logged in.
function update_html_from_login_state(
/* boolean */ user_is_logged_into_app,
/* json */ response) {
var authd = user_is_logged_into_app;
var userId = 1;
// Show or hide relevant sections.
if (authd) {
$('#login-demo-logged-out').removeClass('active');
$('#login-demo-logged-in').addClass('active');
userId = response.authResponse.userID;
} else {
$('#login-demo-logged-out').addClass('active');
$('#login-demo-logged-in').removeClass('active');
}
// Update the profile pic.
$('#profilePic').attr(
'src',
'http://graph.facebook.com/' + userId + '/picture?type=square'
);
// Update the uid field.
$('#uniqueUserId').val(authd ? 'uid='+userId : 'no user id');
};
// When the FB JS SDK is loaded, run this function.
window.fbAsyncInit = function() {
update_html_from_login_state(false, {});
FB.init({
appId : settings.APP_ID, // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.Event.subscribe(
'auth.authResponseChange',
function(response) {
update_html_from_login_state(
response.status === "connected",
response
);
}
);
};
// Load the SDK asynchronously.
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
</script>
</body>
</html>