Socket
Socket
Sign inDemoInstall

facebook-ts

Package Overview
Dependencies
48
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    facebook-ts

Facebook API for Node


Version published
Weekly downloads
6
increased by100%
Maintainers
1
Install size
4.27 MB
Created
Weekly downloads
 

Readme

Source

facebook-ts

A facebook API for the Node.JS backend in TypeScript.

Installation

npm install facebook-ts --save

Usage

// TypeScript
import * as FB from 'facebook-ts'

// JavaScript
var FB = require('facebook-ts')

FB.settings.setSecret('secret-provided-by-facebook');
FB.settings.setClientId('client-id-provided-by-facebook');

FB.getUser('someFacebookId')
    .then(user => { /* ... */ });
    

API

Settings
setSecret
function setSecret(secret: string) => void;

Set the secret as provided by Facebook

getSecret
function getSecret() => string;

Returns the secret that you provided

setClientId
function setClientId(secret: string|number) => void;

Set the client id as provided by Facebook

getClientId
function getClientId() => string;

Returns the client id that you provided

setApiVersion
function setApiVersion(version: string) => void;

...

getApiVersion
function getApiVersion() => string;
accessToken
function accessToken(usedStoredToken = true) => Promise<string>;

Get an access token from Facebook for accessing the rest of the API.
Use the stored token is one is present.

verifyToken
function verifyToken(userStatus: Status) => Promise<TokenStatus>;

See: Status and TokenStatus
Returns the status of a user's session/token.
userStatus is an object provided by the Facebook SDK function getLoginStatus().

getUser
function getUser(facebookId: string|number) => Promise<User>;

See User

Interfaces
Status
interface Status {
    status: string;
    authResponse: {
        accessToken: string;
        expiresIn: string;
        signedRequest: string;
        userID: string;
    }
}
TokenStatus
interface TokenStatus {
    data?: {
        app_id: string;
        application: string;
        expires_at: number;
        is_valid: boolean;
        scopes: Array<string>;
        user_id: string;
        error?: {
            code: number;
            message: string;
            subcode: number;
        }
    },
    error?: {
        message: string,
        type: string,
        is_transient: boolean,
        code: number
    }
}
User
interface User {
    name: string;
    id: string;
}

Keywords

FAQs

Last updated on 18 Oct 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc