# `Exfacebook`
[🔗](https://github.com/oivoodoo/exfacebook/blob/v0.2.0/lib/exfacebook.ex#L1)

Exfacebook implements Graph API:

  * `Exfacebook.Api` - graph calls using access token to Facebook Graph API,
  depends on response it returns decoded to JSON values.

  * `Exfacebook.Config` - specify `api_version` and http requests for hackney.

Configuration example(optional variables):

    config :exfacebook,
      api_version: "v26.0",
      http_options: [recv_timeout: :infinity],
      id: "your_app_id_optional",
      secret: "your_app_secret_optional"

How to use API?

## Examples:

  * `start_link` - if you want to have worker you can start Exfacebook GenServer and use `pid`
  as entry param for API methods:

  ```elixir
  {:ok, pid} = Exfacebook.start_link
  ```

  * `get_object` - get user or page related attributes, in case if you decide to
  use specific params for Facebook API like `fields`

  ```elixir
  {:ok, %{"id" => id, "picture" => picture}} = Exfacebook.get_object(
     pid, :me, %{access_token: "access-token", fields: "id, picture"})
  ```

  * `get_connections` - get collection related items and attributes(feed or home or friends):

  ```elixir
    {:ok, %{"data" => collection}} = response = Exfacebook.get_connections(
       pid, :feed, %{fields: "id, name", access_token: "access-token"})
  ```

  * `next_page`/`prev_page` - take next or prev collections using response from `get_connections`:

  ```elixir
    response = Exfacebook.get_connections(pid, :feed,
       %{fields: "id, name", access_token: "access-token"})
    response2 = Exfacebook.next_page(pid, response)
    response3 = Exfacebook.next_page(pid, response2)
    response4 = Exfacebook.prev_page(pid, response3)
  ```

  * `put_connections` - update actions in facebook, example creates the new message in feed:

  ```elixir
    Exfacebook.put_connections(pid, :me, :feed,
       %{access_token: "access-token"}, %{message: "hello"})
  ```

# `batch`

# `batch`

Passing prepared params for batch processing using Facebook API.

Params are coming like normal requests encoded to JSON and then Facebook
emulate requests on their side:

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `delete_connections`

# `delete_connections`

# `delete_like`

# `delete_like`

# `delete_object`

You can use `delete_object` and `delete_connections` passing pid or directly
from Api module. In case of missing permissions to delete items you will
error object as response.

## Examples:

  * `delete_connections` - delete item from connections
  ```elixir
  {:ok, response} = Exfacebook.Api.delete_connections(:me, :feed, %{ ... })
  ```

  * `delete_object` - delete item from Facebook data
  ```elixir
  {:ok, response} = Exfacebook.Api.delete_object("item-id")
  ```

# `delete_object`

# `exchange_access_token`

Fetches an access token with extended expiration time (ignoring expiration and other info).

# `exchange_access_token_info`

Fetches an access_token with extended expiration time, along with any other information provided by Facebook.
See https://developers.facebook.com/docs/facebook-login/guides/access-tokens/get-long-lived

# `get_connections`

# `get_connections`

# `get_object`

# `get_object`

# `get_picture_data`

API for easy accessing basic Facebook API functions like get avatar image,
put comment, image, video or make wall post.

## Examples:

  * `put_picture` - upload new photo to `id` feed
  ```elixir
  {:ok, response} = Exfacebook.Api.put_picture(:me, params, "/path/file.jpg")
  {:ok, response} = Exfacebook.Api.put_picture(:me, params, {:url, "http://www.example.com/file.jpg"})
  ```

  * `put_video` - upload new video to `id` feed
  ```elixir
  {:ok, response} = Exfacebook.Api.put_video(:me, params, "/path/file.mp4")
  {:ok, response} = Exfacebook.Api.put_video(:me, params, {:url, "http://www.example.com/file.mp4"})
  ```

# `get_picture_data`

# `list_subscriptions`

Realtime updates using subscriptions API

## Examples:

  * `list_subscriptions` - returns list of subscriptions

  ```elixir
  params = %{fields: "id,name"}

  {:ok, %{
    "data" => [
      %{"active" => true,
        "callback_url" => "https://example.com/client/subscriptions",
        "fields" => ["feed", "friends", "music"],
        "object" => "user"}]
    }
  } = Exfacebook.Api.list_subscriptions(params)
  ```

  * `subscribe` - subscribe to real time updates for `object`, `fields` should
  contains object to watch for updates("feed, friends").

  ```elixir
  Exfacebook.Api.subscribe("id-1",
    "friends, feed", "http://www.example.com/facebook/updates",
    "token-123")
  ```

  * `unsubscribe` - unsubscribe `object` from real time updates.

  ```elixir
  Exfacebook.Api.unsubscribe("id-1")
  ```

# `meet_challenge`

Handle a Webhooks verification request. See `Exfacebook.Api.meet_challenge/2`.

# `next_page`

# `next_page`

# `prev_page`

# `prev_page`

# `put_comment`

# `put_comment`

# `put_connections`

# `put_connections`

# `put_like`

Make likes or delete this action for specific post:

## Examples:
  * `put_like` - like object, params should include `access_token`
  ```elixir
  {:ok, response} = Exfacebook.Api.put_like(:me, params)
  ```

  * `delete_like` - unlike object, params should include `access_token`
  ```elixir
  {:ok, response} = Exfacebook.Api.delete_like(:me, params)
  ```

# `put_like`

# `put_picture`

# `put_video`

# `put_wall_post`

# `put_wall_post`

# `start_link`

# `subscribe`

# `unsubscribe`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
