Giter Club home page Giter Club logo

facebook.ex's Introduction

facebook.ex

Build Status

Facebook Graph API Wrapper written in Elixir. (documentation)

Installation

Add facebook.ex as a dependency in your mix.exs file.

defp deps do
  [{:facebook, "~> 0.18.0"}]
end

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 config/dev.exs|test.exs|prod.exs, respectively) with the following keys, which state the library defaults:

config :facebook,
  app_id: nil,
  app_secret: nil,
  app_access_token: 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)!

app_id, app_secret and app_access_token do not need to be supplied if you are using no Graph API calls that require them (e.g. payment calls). If you supply the app_secret, an appsecret_proof will be submitted along with the Graph API requests. The app_secret can be changed (or set) at runtime using Facebook.set_app_secret("<app secret>").

Usage

  1. Register an application on developer.facebook.com
  2. Get an access_token from Facebook's Access Token Tool

Then you can get started with code.

Start an iex shell in your project folder:

$ iex -S mix

Then try some API calls:

iex(1)> Facebook.me("first_name", "ACCESSTOKEN")
{:ok, %{"first_name" => "Michael"}} # <--- that's the return value

iex(2)> Facebook.object_count(:likes, "262588213843476_801732539929038", "ACCESSTOKEN")
{:ok, 48} # <--- that's the return value

Contributing

We encourage contribution from anyone! If you've got an improvement to the documentation or feature you've implemented, please open a pull request. This project uses credo for code analysis. Running mix credo will give you a nice output which will tell you if any of the changes you've made aren't consistent with the rest of our codebase.

The Facebook Graph API is fairly large and as such we're not using every facet of it, so if you're not seeing an edge that is handled, please report an issue or open a pull request to add it.

facebook.ex's People

Contributors

adenisonafifi avatar asolove avatar brinco80 avatar dcarneiro avatar dvdhsu avatar gr8bit avatar hectorip avatar jovannypcg avatar mendab1e avatar mgamini avatar mweibel avatar ne1ro avatar paulruescher avatar potrimpo avatar reset avatar richard-kellermeyer avatar tfinnell avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.