Namespace: Facebook

Cocoon.Social. Facebook

Cocoon.Social.Facebook class provides an easy to use Ads API that can be used with Facebook.

Methods

<static> api(path, method, params, cb)

Makes API calls to the Graph API.

Parameters:
Name Type Description
path

The Graph API url path.

method

The http method (default "GET").

params

The parameters for the query.

cb

The callback function to handle the response.

<static> getAuthResponse() → {object}

Synchronous accessor for the current authResponse.

Returns:

current Facebook session data.

Type
object

<static> getLoginStatus(callback, force)

Allows you to determine if a user is logged in to Facebook and has authenticated your app. There are three possible states for a user:

  1. The user is logged into Facebook and has authenticated your application (connected).
  2. The user is logged into Facebook but has not authenticated your application (not_authorized).
  3. The user is not logged into Facebook at this time and so we don't know if they've authenticated your application or not.
Parameters:
Name Type Description
callback function

The callback function.

force boolean

Force reloading the login status (default false).

<static> getPermissions(callback)

Queries Facebook permissions of the current user.

Parameters:
Name Type Description
callback

Handler function which receives a dictionary with the granted permissions.

<static> getSocialInterface() → {Cocoon.Social.Interface}

Returns a Social Interface for the Facebook Extension. You can use the Facebook extension in two ways, with 1:1 official API equivalent or with the Cocoon API abstraction.

See:
Returns:
Type
Cocoon.Social.Interface

<static> init(options, callback)

Initializes the SDK with your app ID. This will let you make calls against the Facebook API. All FB.API methods must be called after FB.init.

Parameters:
Name Type Description
options object

Check available options here: https://developers.facebook.com/docs/reference/javascript/FB.init/

callback function

The callback function. It receives the following parameters:

  • Error.

<static> login(options)

Authenticates the user. By default, calling login will attempt to authenticate the user with only the basic permissions. If you want one or more additional permissions, call login with an option object, and set the scope parameter with a comma-separated list of the permissions you wish to request from the user.

Parameters:
Name Type Description
options object

Login options.

<static> logout(callback)

Logs the user out of your application. You will need to have a valid access token for the user in order to call the function.

Parameters:
Name Type Description
callback function

Called when the user is logged out.

<static> requestAdditionalPermissions.(permissionsType, permissions, callback)

Allows you to ask additional permission from the current ones.

Parameters:
Name Type Description
permissionsType string

"read" or "publish".

permissions

Comma separated Facebook permission names.

callback

Response authResponse callback.

<static> showShareDialog(params, callback)

Presents a dialog in the Facebook application that allows the user to share a status update. If the Facebook Application is not available it does a fallback to a feed dialog. No publish permissions are required.

Parameters:
Name Type Description
params

Dialog params (description, caption, name, link, picture).

callback

Handler with response data or error.

<static> subscribe(name, callback)

Global Events to which you can subscribe: auth.login - fired when the auth status changes from unknown to connected. auth.authResponseChange - fired when the authResponse changes. auth.statusChange - fired when the status changes.

Parameters:
Name Type Description
name

Name of the event.

callback

The handler function.

<static> ui(params, cb)

A generic method for triggering Dialogs which allow the user to take some action.

Parameters:
Name Type Description
params

The required arguments vary based on the method being used, but specifying the method itself is mandatory.

cb

Callback function to handle the result. Not all methods may have a response.

<static> unsubscribe(name, callback)

Removes handlers on events so it no longer invokes your callback when the event fires.

Parameters:
Name Type Description
name

Name of the event.

callback

The handler function.

<static> uploadPhoto(file, callback)

Upload a local image file to Facebook and get response.

Parameters:
Name Type Description
file

The local file url to submit to Facebook (For example the one capture with screenCapture API).

callback

Handler to process response with the photoid and other data or the error.

Atomic Plugins - JavaScript Documentation by Ludei, DocStrap Copyright © 2012-2013
The contributors to the JSDoc3 and DocStrap projects.