@demimonde/graph

1.0.2 • Public • Published

@demimonde/graph

npm version

@demimonde/graph is The Facebook Graph Methods To Get And Post Data Using Access Tokens.

yarn add -E @demimonde/graph

Table Of Contents

API

The package is available by importing its default function:

import graph from '@demimonde/graph'

graphGet(
  path: string,
  token: string,
  params: Object,
  straight: string,
): void

Makes the call to the get path that can either start or not start with /. The params will be converted to string using querystring.stringify in which the access_token will be embedded.

async graphPost(
  path: string,
  token: string,
  params: Object,
): *

Posts data to the edge.

async getUrl(
  url: string,
  params?: Object,
): *

Stringifies the params and returns the URL for GET request.

async exchange(
  params: { client_id, redirect_uri, client_secret, code } ,
): string

Exchanges the short-lived token for a long-lived token.

facebookDialogUrl(
  params: { client_id, redirect_uri, state, scope } ,
): string

Returns the Oauth URL to sign in into Facebook and allow the app permissions.

import { facebookDialogUrl } from '@demimonde/graph'

const url = facebookDialogUrl({
  client_id: '4hkajshd6f7t4ff',
  redirect_uri: 'http://localhost:4350',
  scope: 'manage_pages',
  state: Math.floor(Math.random() * 10000),
})

console.log(url)
https://www.facebook.com/dialog/oauth?client_id=4hkajshd6f7t4ff&redirect_uri=http%3A%2F%2Flocalhost%3A4350&state=5242&scope=manage_pages

Copyright

(c) Demimonde 2018

Readme

Keywords

Package Sidebar

Install

npm i @demimonde/graph

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

8.53 kB

Total Files

7

Last publish

Collaborators

  • zvr