@demimonde/graph
v1.0.2
Published
The Facebook Graph Methods To Get And Post Data Using Access Tokens.
Downloads
8
Readme
@demimonde/graph
@demimonde/graph
is The Facebook Graph Methods To Get And Post Data Using Access Tokens.
yarn add -E @demimonde/graph
Table Of Contents
- Table Of Contents
- API
graphGet(path: string, token: string, params: Object, straight: string)
async graphPost(path: string, token: string, params: Object): *
async getUrl(url: string, params?: Object): *
async exchange(params: { client_id, redirect_uri, client_secret, code } ): string
facebookDialogUrl(params: { client_id, redirect_uri, state, scope } ): string
- Copyright
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