Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@ After you are done, run this in your shell to fetch the new dependency:
$ mix deps.get
```

## Configuration

You can configure facebook.ex in your mix `config.exs` (or, if you're using the Phoenix Framework, in your `dev/test/prod.exs`, respectively) with the following keys, which state the library defaults:
```
config :facebook,
appsecret: nil,
graph_url: "https://graph.facebook.com",
 graph_video_url: "https://graph-video.facebook.com"
```
For graph_url and video_graph_url, Facebook automatically uses the oldest active Graph API version available if you don't specify a version in the url. You may use versioned urls to pin your calls to a specific API versions (recommended), e.g. like so:
```
graph_url: "https://graph.facebook.com/v2.11",
 graph_video_url: "https://graph-video.facebook.com/v2.8"
```
Note that you *must not* end the urls with a slash or the requests will fail (Facebook will report an error about unknown url components)!

Supplying an appsecret is optional. If you supply it, an [appsecret_proof](https://developers.facebook.com/docs/graph-api/securing-requests) will be submitted along with the Graph API requests. The appsecret can be changed (or set) at runtime using `Facebook.set_appsecret("<app secret>")`.

## Usage

1. Register an application on [developer.facebook.com](https://developer.facebook.com)
Expand Down
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ defmodule Facebook.Mixfile do
applications: [:httpoison, :json, :logger],
env: [
env: :dev,
graph_url: "https://graph.facebook.com/v2.9",
graph_video_url: "https://graph-video.facebook.com/v2.9",
graph_url: "https://graph.facebook.com",
graph_video_url: "https://graph-video.facebook.com",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we really have no version as the default configured anymore? We can increase it certainly but IMO having a sensible default seems preferable.
Also this change makes this PR a breaking change, not just a documentation change ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's the right way for a library to leave (or better: force) the choice of the external api version to the user. Else we would be responsible for keeping it up to date with facebook and every update to the library could introduce incompatibilities for people who rely on the version set by the library. I'd rather have the library have no default at all (and raise if the user doesn't set any url), but I think an "eternal" url (which we don't ever need to change) is also ok in terms of easy entry to the library. True, this became more than a documentation change, sorry. ;) Your choice, you can also leave these url changes out of the merge. :)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a breaking change in #58 as well, so we may as well just increase the major version after merging those two PRs.
I'd like you to next time not mix in unrelated changes to a PR (also in #58 changing the function name of set_appsecret() is such a case). Those changes can be made, but making them in a separate PR is better for visibility and to be able to accept/decline the PRs separately.

appsecret: nil
]
]
Expand Down