2.1.0 • Published 3 years ago

@p803/facebook-sdk v2.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

Facebook SDK for JavaScript

This repository contains a JavaScript package that allows you to access the Facebook SDK for JavaScript from your JavaScript project.

Installation

This package can be installed with npm. Run this command:

npm install @p803/facebook-sdk

or use the standalone format:

<script src="https://unpkg.com/@p803/facebook-sdk"></script>

Usage

Let's see how the official login example will look like when using this SDK.

// Import the package.
import facebookSdk from '@p803/facebook-sdk'   // node
// const facebookSdk = window.p803.facebookSdk // browser

// Set sdk parameters.
facebookSdk.params = {
    appId: '{app-id}', // required
    version: 'v6.0',   // required
    xfbml: true,       // optional
    // other params...
}

// Grab the sdk.
const sdk = await facebookSdk()

// Login the user.
const response = await sdk.login({
    scope: ['email', 'user_likes'],
    return_scopes: true,
});

// Print details.
if (response.authResponse) {
    const me = await sdk.api('/me');

    console.log(`Good to see you, ${me.name}.`);
} else {
    console.log('User cancelled login or did not fully authorize.');
}

// ...

// Subsequent calls will return the same sdk instance.
const sdk = await facebookSdk(); // it's singleton
2.1.0

3 years ago

2.0.9

4 years ago

2.0.7

4 years ago

2.0.8

4 years ago

2.0.5

4 years ago

2.0.6

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.4

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.2.2

4 years ago

1.3.0

4 years ago

1.2.1

4 years ago

0.2.0

4 years ago

1.2.0

4 years ago

0.1.0

4 years ago