Using one social network API is easy. But using multiple ones throughout your app, is not only is tedious, but very frustrating due to each API being soooo different from one another. The response objects, the methods, the parameters, everything.
This library aims to make things easier for you by giving you a common interface for each social network API. Each network's API can be accessed using the same method names and response objects that follow the same schema.
Supports the following APIs:
You can pass a standardized set of options to each API:
|appId||String||The application ID supplied by the network||Yes|
|version||String||The api version to use||Yes|
|apiKey||String||The application key used to access the network's API||No|
|apiSecret||String||The application secret used to access the network's API||No|
Certain networks allow additional
options outside of the ones we support. You can also pass these as
Please see the documentation of the network to find out which addition
options properties you can to pass.
;let fb = appId: 'MyAP33IYEK3y';
This method allows you to lazily load the api of any social network. It will inject and load any scripts that are required to use the API. It also returns a promise that is the API object of the network.
The following example uses Facebook, but you can also follow this same pattern for each of the other network interfaces (Twitter, Tumblr, Instagram, Vine, etc);
;let fb = appId: 'MyAP33IYEK3y';fb;
Use this method to log a user into any social network to retrieve the user's access token. You will need this token to make API calls.
|permissions||Array||The permissions to request from the user when logging in||||No|
Passing a array of pre-determined permissions to the
login() method will map to the appropriate permissions
to the specific social network you've requested. Here's an example using the Facebook social network.
// request permissions to create posts for the user, read the user's posts, and read their connection's profiles.var permissions = 'createPosts' 'readPosts' 'readFriendProfiles';;
Generally permissions follow the CRUD methodology when manipulating persistent data. The following are all permissions currently available which applies to all social networks available in this package.
||Create posts on behalf of the user.|
||Read the user's posts.|
||Update the user's posts (if social network allows it).|
||Remove a user's posts (if social network allows it).|
||Read a user's profile information.|
||Read profiles of the user's friends.|
login() method will return a promise that will resolve with an object with the following properties
when the user has completed the login flow.
|accessToken||String||The user token|
|accessTokenSecret||String||The user token secret|
|userId||String||The id of the user|
|expiresAt||Date||The date (and time) the user's token will expire|
- Facebook requires you to call
login()after a user interaction, like a click on a button for instance. If you attempt to call
login()without a user interaction, most browsers will block it.
- Twitter, most of the time, will require you to go into your application settings for your app and enable the "Allow this application to be used to Sign in with Twitter?" option.
All pull requests are welcome!
To run tests: