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

Basic functions for accessing the Facebook Graph API.

# `access_token`

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

# `api`

```elixir
@type api() :: list()
```

# `body`

```elixir
@type body() :: map()
```

# `error`

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

# `file`

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

# `id`

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

# `name`

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

# `params`

```elixir
@type params() :: map()
```

# `success`

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

# `appsecret_proof`

```elixir
@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`

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

Use `delete_connections` to delete object from connections

Example:

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

# `delete_connections`

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

Use `delete_connections` for deleting items from connections using batch api

# `delete_object`

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

Use `delete_object` to delete object from facebook data.

Example:

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

# `delete_object`

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

Use `delete_object` for deleting item from facebook data.

# `get_connections`

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

Use `get_connections` to read feed, home collections.

Example:

  {:ok, %{"data" => collection}} = get_connections(:me, :feed, %{fields: "id, name"})

# `get_connections`

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

Use `get_connections` for getting collection using batch Facebook API.

# `get_object`

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

Use `get_object` for getting object related attributes

Example:

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

# `get_object`

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

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

# `get_picture_data`

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

Returns hash of image data for passed id.

# `list_subscriptions`

```elixir
@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`

```elixir
@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`

```elixir
@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`

```elixir
@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`

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

Use `put_connections` for posting messages or other update actions.

# `subscribe`

```elixir
@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`

```elixir
@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.

---

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