-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.html
545 lines (391 loc) · 15.9 KB
/
README.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
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
lang="en" xml:lang="en">
<head>
<title>README</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<meta name="generator" content="Org-mode"/>
<meta name="generated" content="2010-11-29 07:32:57 PST"/>
<meta name="author" content="Jason Walsh"/>
<meta name="description" content=""/>
<meta name="keywords" content=""/>
<style type="text/css">
<!--/*--><![CDATA[/*><!--*/
html { font-family: Times, serif; font-size: 12pt; }
.title { text-align: center; }
.todo { color: red; }
.done { color: green; }
.tag { background-color: #add8e6; font-weight:normal }
.target { }
.timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; }
p.verse { margin-left: 3% }
pre {
border: 1pt solid #AEBDCC;
background-color: #F3F5F7;
padding: 5pt;
font-family: courier, monospace;
font-size: 90%;
overflow:auto;
}
table { border-collapse: collapse; }
td, th { vertical-align: top; }
dt { font-weight: bold; }
div.figure { padding: 0.5em; }
div.figure p { text-align: center; }
.linenr { font-size:smaller }
.code-highlighted {background-color:#ffff00;}
.org-info-js_info-navigation { border-style:none; }
#org-info-js_console-label { font-size:10px; font-weight:bold;
white-space:nowrap; }
.org-info-js_search-highlight {background-color:#ffff00; color:#000000;
font-weight:bold; }
/*]]>*/-->
</style>
<script type="text/javascript">
<!--/*--><![CDATA[/*><!--*/
function CodeHighlightOn(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.cacheClassElem = elem.className;
elem.cacheClassTarget = target.className;
target.className = "code-highlighted";
elem.className = "code-highlighted";
}
}
function CodeHighlightOff(elem, id)
{
var target = document.getElementById(id);
if(elem.cacheClassElem)
elem.className = elem.cacheClassElem;
if(elem.cacheClassTarget)
target.className = elem.cacheClassTarget;
}
/*]]>*///-->
</script>
</head>
<body>
<div id="content">
<h1 class="title">README</h1>
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#sec-1">1 Background </a></li>
<li><a href="#sec-2">2 Setup </a>
<ul>
<li><a href="#sec-2.1">2.1 Check out the files for the system to a sandbox </a></li>
<li><a href="#sec-2.2">2.2 Link or move the sandbox location to a directory under the document root of the web server </a></li>
<li><a href="#sec-2.3">2.3 Validate that http://localhost/wpogfc/ renders "Compare Your Friends on Facebook" </a></li>
<li><a href="#sec-2.4">2.4 Select a domain for hosting the application</a></li>
<li><a href="#sec-2.5">2.5 Create an Application</a></li>
<li><a href="#sec-2.6">2.6 Update lib/config.js with the new appId</a></li>
</ul>
</li>
<li><a href="#sec-3">3 Implementation </a>
<ul>
<li><a href="#sec-3.1">3.1 Directory structure and base file setup </a></li>
<li><a href="#sec-3.2">3.2 Library implementation </a></li>
<li><a href="#sec-3.3">3.3 Manually acquire a list of friends and likes </a></li>
<li><a href="#sec-3.4">3.4 Facebook Connect </a></li>
<li><a href="#sec-3.5">3.5 Render likes for authenticated user </a></li>
<li><a href="#sec-3.6">3.6 Create binding when selecting a user </a></li>
<li><a href="#sec-3.7">3.7 Create UI clearing when selecting a new user </a></li>
<li><a href="#sec-3.8">3.8 friends.get </a></li>
<li><a href="#sec-3.9">3.9 Expand permissions </a></li>
<li><a href="#sec-3.10">3.10 friends.getMutualFriends </a></li>
<li><a href="#sec-3.11">3.11 Refactor for the final workflow of the UI </a></li>
<li><a href="#sec-3.12">3.12 Research token request failures for FB.api() </a></li>
<li><a href="#sec-3.13">3.13 Push in jsDoc utilities </a></li>
<li><a href="#sec-3.14">3.14 Switch to mustache for templated rendering </a></li>
<li><a href="#sec-3.15">3.15 Mock JSON setup for unit tests </a></li>
<li><a href="#sec-3.16">3.16 Simplify API for sh.wal.wpogfc </a></li>
</ul>
</li>
<li><a href="#sec-4">4 Tests </a>
<ul>
<li><a href="#sec-4.1">4.1 init without session </a></li>
<li><a href="#sec-4.2">4.2 Intersection of likes </a></li>
<li><a href="#sec-4.3">4.3 Intersection of friends </a></li>
</ul>
</li>
<li><a href="#sec-5">5 Resources </a></li>
</ul>
</div>
</div>
<div id="outline-container-1" class="outline-2">
<h2 id="sec-1"><span class="section-number-2">1</span> Background </h2>
<div class="outline-text-2" id="text-1">
<p>
Use the Facebook API and create an application that will allow me to log in and pick one of my friends and see all of our common interest and common friends.
</p>
</div>
</div>
<div id="outline-container-2" class="outline-2">
<h2 id="sec-2"><span class="section-number-2">2</span> Setup </h2>
<div class="outline-text-2" id="text-2">
</div>
<div id="outline-container-2.1" class="outline-3">
<h3 id="sec-2.1"><span class="section-number-3">2.1</span> Check out the files for the system to a sandbox </h3>
<div class="outline-text-3" id="text-2.1">
<pre class="example">git clone git://github.com/jwalsh/wpogfc.git
</pre>
</div>
</div>
<div id="outline-container-2.2" class="outline-3">
<h3 id="sec-2.2"><span class="section-number-3">2.2</span> Link or move the sandbox location to a directory under the document root of the web server </h3>
<div class="outline-text-3" id="text-2.2">
<p>
If using localhost with external linking to a non-root location a
</p>
<pre class="example">sudo ln -s ~/sandbox/wpogfc /opt/local/html
</pre>
</div>
</div>
<div id="outline-container-2.3" class="outline-3">
<h3 id="sec-2.3"><span class="section-number-3">2.3</span> Validate that <a href="http://localhost/wpogfc/">http://localhost/wpogfc/</a> renders "Compare Your Friends on Facebook" </h3>
<div class="outline-text-3" id="text-2.3">
</div>
</div>
<div id="outline-container-2.4" class="outline-3">
<h3 id="sec-2.4"><span class="section-number-3">2.4</span> Select a domain for hosting the application <span class="tag"><span class="optional">optional</span></span></h3>
<div class="outline-text-3" id="text-2.4">
<p>
For sandbox review this can be completed with
</p>
<pre class="example">http://localhost/wpogfc/
</pre>
<p>
assuming a symlink to the directory was provided above.
</p>
<p>
Assuming only localhost is used the default configuration should work.
</p>
</div>
</div>
<div id="outline-container-2.5" class="outline-3">
<h3 id="sec-2.5"><span class="section-number-3">2.5</span> Create an Application <span class="tag"><span class="optional">optional</span></span></h3>
<div class="outline-text-3" id="text-2.5">
<p>
<a href="http://developers.facebook.com/setup/">http://developers.facebook.com/setup/</a>
</p>
<ul>
<li>
Site name: wpogfc
</li>
<li>
Site URL: <a href="http://localhost/wpogfc">http://localhost/wpogfc</a>
</li>
<li>
Locale: [default]
</li>
</ul>
<p>At the end of the application process you should have access to a review page like:
</p>
<pre class="example">http://www.facebook.com/developers/apps.php?app_id=146334962085649
</pre>
</div>
</div>
<div id="outline-container-2.6" class="outline-3">
<h3 id="sec-2.6"><span class="section-number-3">2.6</span> Update lib/config.js with the new appId <span class="tag"><span class="optional">optional</span></span></h3>
<div class="outline-text-3" id="text-2.6">
<p>
This should only be necessary when not using localhost.
</p>
</div>
</div>
</div>
<div id="outline-container-3" class="outline-2">
<h2 id="sec-3"><span class="section-number-2">3</span> Implementation </h2>
<div class="outline-text-2" id="text-3">
</div>
<div id="outline-container-3.1" class="outline-3">
<h3 id="sec-3.1"><span class="section-number-3">3.1</span> <span class="done DONE"> DONE</span> Directory structure and base file setup </h3>
<div class="outline-text-3" id="text-3.1">
</div>
</div>
<div id="outline-container-3.2" class="outline-3">
<h3 id="sec-3.2"><span class="section-number-3">3.2</span> <span class="done DONE"> DONE</span> Library implementation </h3>
<div class="outline-text-3" id="text-3.2">
<p>
Using jQuery for manipulating DOM elements and XHR. Underscore added for Array extras.
</p>
</div>
</div>
<div id="outline-container-3.3" class="outline-3">
<h3 id="sec-3.3"><span class="section-number-3">3.3</span> <span class="done DONE"> DONE</span> Manually acquire a list of friends and likes </h3>
<div class="outline-text-3" id="text-3.3">
<p>
Use the hardcoded OAuth token from the sample page.
</p>
</div>
</div>
<div id="outline-container-3.4" class="outline-3">
<h3 id="sec-3.4"><span class="section-number-3">3.4</span> <span class="done DONE"> DONE</span> Facebook Connect </h3>
<div class="outline-text-3" id="text-3.4">
<p>
<a href="http://developers.facebook.com/docs/reference/javascript/">http://developers.facebook.com/docs/reference/javascript/</a>
</p>
<p>
<a href="http://developers.facebook.com/docs/guides/web">http://developers.facebook.com/docs/guides/web</a>
</p>
</div>
</div>
<div id="outline-container-3.5" class="outline-3">
<h3 id="sec-3.5"><span class="section-number-3">3.5</span> <span class="done DONE"> DONE</span> Render likes for authenticated user </h3>
<div class="outline-text-3" id="text-3.5">
</div>
</div>
<div id="outline-container-3.6" class="outline-3">
<h3 id="sec-3.6"><span class="section-number-3">3.6</span> <span class="done DONE"> DONE</span> Create binding when selecting a user </h3>
<div class="outline-text-3" id="text-3.6">
<p>
Default to alert() just for showing the required information needed to pass to
</p>
</div>
</div>
<div id="outline-container-3.7" class="outline-3">
<h3 id="sec-3.7"><span class="section-number-3">3.7</span> <span class="done DONE"> DONE</span> Create UI clearing when selecting a new user </h3>
<div class="outline-text-3" id="text-3.7">
</div>
</div>
<div id="outline-container-3.8" class="outline-3">
<h3 id="sec-3.8"><span class="section-number-3">3.8</span> <span class="done DONE"> DONE</span> friends.get </h3>
<div class="outline-text-3" id="text-3.8">
<p>
<a href="http://developers.facebook.com/docs/reference/rest/friends.get">http://developers.facebook.com/docs/reference/rest/friends.get</a>
</p>
</div>
</div>
<div id="outline-container-3.9" class="outline-3">
<h3 id="sec-3.9"><span class="section-number-3">3.9</span> <span class="done DONE"> DONE</span> Expand permissions </h3>
<div class="outline-text-3" id="text-3.9">
<p>
{
"error": {
"type": "OAuthException",
"message": "(#604) Can't lookup all friends of 10720515. Can only lookup for the logged in user (1178471455), or friends of the logged in user with the appropriate permission"
}
}
</p>
</div>
</div>
<div id="outline-container-3.10" class="outline-3">
<h3 id="sec-3.10"><span class="section-number-3">3.10</span> <span class="done DONE"> DONE</span> friends.getMutualFriends </h3>
<div class="outline-text-3" id="text-3.10">
<p>
<a href="http://developers.facebook.com/docs/reference/rest/friends.getMutualFriends">http://developers.facebook.com/docs/reference/rest/friends.getMutualFriends</a>
</p>
<p>
<?xml version="1.0" encoding="UTF-8"?>
<friends<sub>getMutualFriends</sub><sub>response</sub> xmlns="<a href="http://api.facebook.com/1.0/"">http://api.facebook.com/1.0/"</a> xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance"">http://www.w3.org/2001/XMLSchema-instance"</a> xsi:schemaLocation="<a href="http://api.facebook.com/1.0/">http://api.facebook.com/1.0/</a> <a href="http://api.facebook.com/1.0/facebook.xsd"">http://api.facebook.com/1.0/facebook.xsd"</a> list="true">
<uid>10732378</uid>
<uid>586317678</uid>
<uid>641709854</uid>
<uid>710480979</uid>
<uid>749820125</uid>
<uid>1029541308</uid>
<uid>1222026451</uid>
<uid>1362995778</uid>
</friends<sub>getMutualFriends</sub><sub>response></sub>;
</p>
<p>
This is the deprecated REST API which appears to only return XML.
</p>
<p>
Would require nginx proxy setup for all of the API calls.
</p>
<p>
On a second review of
</p>
<p>
<a href="https://api.facebook.com/method/friends.getMutualFriends?target_uid=10732378&access_token=2227470867|2.Xf8VlYutArwGqBgDo5X5XQ__.3600.1291042800-1178471455|ts9ZN5aaXG-qf8oRghPJd4a2SJE&format=json">https://api.facebook.com/method/friends.getMutualFriends?target_uid=10732378&access_token=2227470867|2.Xf8VlYutArwGqBgDo5X5XQ__.3600.1291042800-1178471455|ts9ZN5aaXG-qf8oRghPJd4a2SJE&format=json</a>
</p>
<p>
this seemed to work.
</p>
</div>
</div>
<div id="outline-container-3.11" class="outline-3">
<h3 id="sec-3.11"><span class="section-number-3">3.11</span> <span class="done DONE"> DONE</span> Refactor for the final workflow of the UI </h3>
<div class="outline-text-3" id="text-3.11">
</div>
</div>
<div id="outline-container-3.12" class="outline-3">
<h3 id="sec-3.12"><span class="section-number-3">3.12</span> <span class="done DONE"> DONE</span> Research token request failures for FB.api() </h3>
<div class="outline-text-3" id="text-3.12">
<pre class="example">// Test from http://developers.facebook.com/docs/reference/javascript/FB.api
var body = 'Reading Connect JS documentation';
FB.api('/me/feed', 'post', { body: body }, function(response) {
if (!response || response.error) {
console.error(response.error);
} else {
alert('Post ID: ' + response);
}
});
</pre>
</div>
</div>
<div id="outline-container-3.13" class="outline-3">
<h3 id="sec-3.13"><span class="section-number-3">3.13</span> <span class="todo TODO"> TODO</span> Push in jsDoc utilities </h3>
<div class="outline-text-3" id="text-3.13">
</div>
</div>
<div id="outline-container-3.14" class="outline-3">
<h3 id="sec-3.14"><span class="section-number-3">3.14</span> <span class="todo TODO"> TODO</span> Switch to mustache for templated rendering </h3>
<div class="outline-text-3" id="text-3.14">
</div>
</div>
<div id="outline-container-3.15" class="outline-3">
<h3 id="sec-3.15"><span class="section-number-3">3.15</span> <span class="todo TODO"> TODO</span> Mock JSON setup for unit tests </h3>
<div class="outline-text-3" id="text-3.15">
</div>
</div>
<div id="outline-container-3.16" class="outline-3">
<h3 id="sec-3.16"><span class="section-number-3">3.16</span> Simplify API for sh.wal.wpogfc </h3>
<div class="outline-text-3" id="text-3.16">
</div>
</div>
</div>
<div id="outline-container-4" class="outline-2">
<h2 id="sec-4"><span class="section-number-2">4</span> Tests </h2>
<div class="outline-text-2" id="text-4">
</div>
<div id="outline-container-4.1" class="outline-3">
<h3 id="sec-4.1"><span class="section-number-3">4.1</span> init without session </h3>
<div class="outline-text-3" id="text-4.1">
</div>
</div>
<div id="outline-container-4.2" class="outline-3">
<h3 id="sec-4.2"><span class="section-number-3">4.2</span> Intersection of likes </h3>
<div class="outline-text-3" id="text-4.2">
</div>
</div>
<div id="outline-container-4.3" class="outline-3">
<h3 id="sec-4.3"><span class="section-number-3">4.3</span> Intersection of friends </h3>
<div class="outline-text-3" id="text-4.3">
</div>
</div>
</div>
<div id="outline-container-5" class="outline-2">
<h2 id="sec-5"><span class="section-number-2">5</span> Resources </h2>
<div class="outline-text-2" id="text-5">
<p>
<a href="https://github.com/facebook/connect-js">https://github.com/facebook/connect-js</a>
<a href="https://github.com/jquery/jquery">https://github.com/jquery/jquery</a>
<a href="https://github.com/documentcloud/underscore/">https://github.com/documentcloud/underscore/</a>
</p></div>
</div>
<div id="postamble">
<p class="author"> Author: Jason Walsh
<a href="mailto:[email protected]"><[email protected]></a>
</p>
<p class="date"> Date: 2010-11-29 07:32:57 PST</p>
<p class="creator">HTML generated by org-mode 6.33x in emacs 23</p>
</div>
</div>
</body>
</html>