Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/seikho/facebook-ts
Facebook API for the Node.JS backend in TypeScript
https://github.com/seikho/facebook-ts
Last synced: 5 days ago
JSON representation
Facebook API for the Node.JS backend in TypeScript
- Host: GitHub
- URL: https://github.com/seikho/facebook-ts
- Owner: Seikho
- License: mit
- Created: 2015-09-24T10:05:11.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-18T06:48:18.000Z (about 9 years ago)
- Last Synced: 2024-09-29T20:54:38.032Z (about 1 month ago)
- Language: JavaScript
- Size: 195 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
### facebook-ts
A facebook API for the Node.JS backend in TypeScript.### Installation
```
npm install facebook-ts --save
```### Usage
```javascript
// 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
```javascript
function setSecret(secret: string) => void;
```
Set the secret as provided by Facebook##### getSecret
```javascript
function getSecret() => string;
```
Returns the secret that you provided##### setClientId
```javascript
function setClientId(secret: string|number) => void;
```
Set the client id as provided by Facebook##### getClientId
```javascript
function getClientId() => string;
```
Returns the client id that you provided##### setApiVersion
```javascript
function setApiVersion(version: string) => void;
```
...##### getApiVersion
```javascript
function getApiVersion() => string;
```#### accessToken
```javascript
function accessToken(usedStoredToken = true) => Promise;
```
Get an access token from Facebook for accessing the rest of the API.
Use the stored token is one is present.#### verifyToken
```javascript
function verifyToken(userStatus: Status) => Promise;
```
See: [Status](#status) and [TokenStatus](#tokenstatus)
Returns the status of a user's session/token.
`userStatus` is an object provided by the Facebook SDK function `getLoginStatus()`.#### getUser
```javascript
function getUser(facebookId: string|number) => Promise;
```
See [User](#user)#### Interfaces
##### Status
```javascript
interface Status {
status: string;
authResponse: {
accessToken: string;
expiresIn: string;
signedRequest: string;
userID: string;
}
}
```##### TokenStatus
```javascript
interface TokenStatus {
data?: {
app_id: string;
application: string;
expires_at: number;
is_valid: boolean;
scopes: Array;
user_id: string;
error?: {
code: number;
message: string;
subcode: number;
}
},
error?: {
message: string,
type: string,
is_transient: boolean,
code: number
}
}
```##### User
```javascript
interface User {
name: string;
id: string;
}
```