1.0.0 • Published 4 years ago

contentware-pi v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

Contentware Platform Integration Social platform integration Typescript SDK libary

Build the library

npm install (Need only first time or dependencies are modified)
npm run build

Install library locally

  • Go to your project root folder which has package.json file
  • Execute following command
npm install relative-file-path
e.g. npm install "..\..\Contentware\contentware-pi

Get Facebook oAuth2 login URL

const contentwarePi = require('contentware-pi');
const facebookClient = new contentwarePi.FacebookClient(appId, appSecret);
const loginUrl = facebookClient.getOAuth2LoginUrl({
    redirectUrl: 'http://localhost:4003/callback',
    state: 'State',
});

Facebook login callback

const contentwarePi = require('contentware-pi');
const facebookClient = new contentwarePi.FacebookClient(appId, appSecret);
const loginUrl = facebookClient.getOAuth2LoginUrl({
    redirectUrl: 'http://localhost:4003/callback',
    state: 'State',
});
facebookClient.loginCallback(loginUrl.accessToken);

Publish a post on Facebook

const contentwarePi = require('contentware-pi');
const facebookClient = new contentwarePi.FacebookClient(appId, appSecret);
const loginUrl = facebookClient.getOAuth2LoginUrl({
    redirectUrl: 'http://localhost:4003/callback',
    state: 'State',
});
const userAccess = facebookClient.loginCallback(loginUrl.accessToken);
facebookClient.publishPost({
    accessToken: userAccess.accessToken,
    pageId: userAccess.pageId,
    link: userAccess.link, // should be URL
    message: userAccess.message,
    published: false,
    scheduled_publish_time: userAccess.publishTime, // In timestamp. The post should not be published before, if published use published: false
});
1.0.0

4 years ago