Exfacebook.Api (exfacebook v0.2.0)

Copy Markdown View Source

Basic functions for accessing the Facebook Graph API.

Summary

Functions

HMAC-SHA256 of the access token using the app secret.

Use delete_connections to delete object from connections

Use delete_connections for deleting items from connections using batch api

Use delete_object to delete object from facebook data.

Use delete_object for deleting item from facebook data.

Use get_connections to read feed, home collections.

Use get_connections for getting collection using batch Facebook API.

Use get_object for getting object related attributes

Use get_object for getting object related attributes as part of batch API.

Returns hash of image data for passed id.

Getting list of subscriptions for app, we don't need to use user access token, it requires to have only app_id and secret.

Handle a Webhooks verification request.

Pagination next_page is using response from calls of get_connections.

Use put_connections for posting messages or other update actions.

Use put_connections for posting messages or other update actions.

Subscribe to real time updates to object.

id - id of object to unsubscribe, in case if developer passed nil unsubscribe would apply for all subscriptions for facebook app.

Types

access_token()

@type access_token() :: String.t()

api()

@type api() :: list()

body()

@type body() :: map()

error()

@type error() :: {:error, Exfacebook.Error.t()}

file()

@type file() :: String.t() | tuple()

id()

@type id() :: String.t() | atom()

name()

@type name() :: String.t()

params()

@type params() :: map()

success()

@type success() :: {:ok, map()}

Functions

appsecret_proof(access_token)

@spec appsecret_proof(String.t()) :: String.t() | nil

HMAC-SHA256 of the access token using the app secret.

Source: https://developers.facebook.com/docs/graph-api/guides/secure-requests/

delete_connections(id, name, params)

@spec delete_connections(id(), name(), params()) :: success() | error()

Use delete_connections to delete object from connections

Example:

= delete_connections(:me, :feed, %{})

delete_connections(api, id, name, params)

@spec delete_connections(api(), id(), name(), params()) :: api()

Use delete_connections for deleting items from connections using batch api

delete_object(id, params)

@spec delete_object(id(), params()) :: success() | error()

Use delete_object to delete object from facebook data.

Example:

= delete_object("item-id", %{})

delete_object(api, id, params)

@spec delete_object(api(), id(), params()) :: api()

Use delete_object for deleting item from facebook data.

get_connections(id, name, params)

@spec get_connections(id(), name(), params()) :: success() | error()

Use get_connections to read feed, home collections.

Example:

} = get_connections(:me, :feed, %{fields: "id, name"})

get_connections(api, id, name, params)

@spec get_connections(api(), id(), name(), params()) :: api()

Use get_connections for getting collection using batch Facebook API.

get_object(id, params)

@spec get_object(id(), params()) :: success() | error()

Use get_object for getting object related attributes

Example:

} = get_object(:me, %{access_token: "access-token", fields: "id, name"})

get_object(api, id, params)

@spec get_object(api(), id(), params()) :: api()

Use get_object for getting object related attributes as part of batch API.

get_picture_data(id, params)

@spec get_picture_data(id(), params()) :: success() | error()

Returns hash of image data for passed id.

list_subscriptions(params)

@spec list_subscriptions(params()) :: success() | error()

Getting list of subscriptions for app, we don't need to use user access token, it requires to have only app_id and secret.

meet_challenge(params, verify_token)

@spec meet_challenge(map(), String.t()) :: {:ok, String.t()} | error()

Handle a Webhooks verification request.

Facebook sends hub.mode, hub.verify_token, and hub.challenge. Return {:ok, challenge} when the request is valid.

Source: https://developers.facebook.com/docs/graph-api/webhooks/getting-started

next_page(state)

@spec next_page(success() | error()) :: success() | error()

Pagination next_page is using response from calls of get_connections.

Example:

page0 = get_connections(...)
page1 = page0 |> next_page
page0 = page1 |> prev_page

put_connections(id, name, params, body \\ %{})

@spec put_connections(id(), name(), params(), body()) :: success() | error()

Use put_connections for posting messages or other update actions.

Example:

put_connections(:me, :feed, %{access_token: "access-token"}, %{message: "message-example"})

put_connections(api, id, name, params, body)

@spec put_connections(api(), id(), name(), params(), body()) :: api()

Use put_connections for posting messages or other update actions.

subscribe(id, fields, callback_url, verify_token \\ nil)

@spec subscribe(id(), String.t(), String.t(), String.t() | nil) :: success() | error()

Subscribe to real time updates to object.

callback_url - https api endpoint to receive real time updates. verify_token - token to verify post request from facebook with updates. fields - 'friends, feed' as an example.

unsubscribe(id)

@spec unsubscribe(id()) :: success() | error()

id - id of object to unsubscribe, in case if developer passed nil unsubscribe would apply for all subscriptions for facebook app.