Skip to content

walsh/wpogfc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Background

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.

Setup

Check out the files for the system to a sandbox

git clone git://github.com/jwalsh/wpogfc.git

Link or move the sandbox location to a directory under the document root of the web server

If using localhost with external linking to a non-root location a

sudo ln -s ~/sandbox/wpogfc /opt/local/html

Validate that http://localhost/wpogfc/ renders “Compare Your Friends on Facebook”

Select a domain for hosting the application

For sandbox review this can be completed with

http://localhost/wpogfc/

assuming a symlink to the directory was provided above.

Assuming only localhost is used the default configuration should work.

Create an Application

http://developers.facebook.com/setup/

  • Site name: wpogfc
  • Site URL: http://localhost/wpogfc
  • Locale: [default]

At the end of the application process you should have access to a review page like:

Update lib/config.js with the new appId

This should only be necessary when not using localhost.

Implementation

Directory structure and base file setup

Library implementation

Using jQuery for manipulating DOM elements and XHR. Underscore added for Array extras.

[#B] Manually acquire a list of friends and likes

Use the hardcoded OAuth token from the sample page.

Facebook Connect

Render likes for authenticated user

Create binding when selecting a user

Default to alert() just for showing the required information needed to pass to the REST call.

Create UI clearing when selecting a new user

friends.get

http://developers.facebook.com/docs/reference/rest/friends.get

Expand permissions

{
   "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"
   }
}

friends.getMutualFriends

http://developers.facebook.com/docs/reference/rest/friends.getMutualFriends

<?xml version="1.0" encoding="UTF-8"?>
<friends_getMutualFriends_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" 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_getMutualFriends_response>

This is the deprecated REST API which initially appeared to only return XML which would have required an nginx proxy setup for all of the API calls.

On a second review of the JavaScript test console though the link provided a format parameter to specify JSON:

Refactor for the final workflow of the UI

Research token request failures for FB.api()

     // 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);
		}
	      });

Push in jsDoc utilities

Switch to mustache for templated rendering

Mock JSON setup for unit tests

Simplify API for sh.wal.wpogfc

Tests

init without session

Intersection of likes

Intersection of friends

Resources

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published