socialz
v1.0.1
Published
A package which provides you with the analytics of major social media platforms.
Downloads
1
Maintainers
Readme
socialz
A package which provides you with the analytics of major social media platforms.
Supported social media platforms
- Tiktok
- Youtube
Installation Guide
Install the package in your js/ts appication.
npm install socialz
OR
yarn add socialz
Integration Guide
Create facebook developer account. (https://developers.facebook.com/)
Create facebook app. (https://developers.facebook.com/apps/?show_reminder=true)
Configure facebook login for your facebook app. (https://developers.facebook.com/apps/{your-app-id}/fb-login/settings/)
Add your application's server URL in Valid OAuth Redirect URIs input.
Import Facebook constructor from the sdk. Create Facebook instance.
import { Facebook } from 'socialX';
const facebook = new Facebook({
apiKey: '',
apiSecret: '',
redirectLink: '',
});
You'll find apiKey
as App ID and apiSecret
as App Secret from your facebook app's basic settings.
Methods
facebook.getAuthorizationLink()
returns authorization link which you can attach to your login with facebook button. After successful authorization facebook will redirect user to the redirect link you provided in the constructor with authorization code in query params.
facebook.getUserAccessToken(_authorizationToken)
returns user's access token which is obtained after successful authorization from authorization link above.
facebook.getUserDetails(_accessToken)
returns user's profile info. Function takes in access token which is obtained using getUserAccessToken function.
facebook.getUserLatestPosts(_accessToken)
returns user's latest posts list. Function takes in access token which is obtained using getUserAccessToken function.
facebook.getPostDetails(_postIdentifiers, _accessToken)
returns user's post details list. Function takes in an array of post identifiers, these are obtained using getUserLatestPosts function. Function takes in access token which is obtained using getUserAccessToken function.
Before you start you'll need.
- An Instagram Business Account or Instagram Creator Account
- A Facebook Page connected to that account
- A Facebook Developer account that can perform Tasks on that Page
- A registered Facebook App with Basic settings configured
Configure facebook login for your facebook app with permissions. (https://developers.facebook.com/apps/{your-app-id}/fb-login/settings/)
Add your application's server URL in Valid OAuth Redirect URIs input.
Import Instagram constructor from the sdk. Create Facebook instance.
import { Instagram } from 'socialX';
const instagram = new Instagram({
apiKey: '',
apiSecret: '',
redirectLink: '',
});
You'll find apiKey
as App ID and apiSecret
as App Secret from your facebook app's basic settings.
Methods
instagram.getAuthorizationLink()
returns authorization link which you can attach to your login with instagram button. After successful authorization instagram will redirect user to the redirect link you provided in the constructor with authorization code in query params.
instagram.getUserAccessToken(_authorizationToken)
returns user's access token which is obtained after successful authorization from authorization link above.
instagram.getUserDetails(_accessToken)
returns user's profile info. Function takes in access token which is obtained using getUserAccessToken function.
instagram.getUserLatestPosts(_accessToken)
returns user's latest posts list. Function takes in access token which is obtained using getUserAccessToken function.
instagram.getPostDetails(_postIdentifiers, _accessToken)
returns user's post details list. Function takes in an array of post identifiers, these are obtained using getUserLatestPosts function. Function takes in access token which is obtained using getUserAccessToken function.
Tiktok
Create Tiktok developer account.
Create Tiktok app. (https://developers.tiktok.com/apps/)
Fill in the basic information on Tiktok application dashboard.
Add login kit and Video kit as product in your Tiktok application.
In login kit find input with label Redirect domain, and add your application server's domain in it.
In Tiktok api section found at the bottom of Tiktok application dashboard. Add user.info.basic and video.list as scopes.
Submit your app for review. Tiktok SDK won't work if your app is not approved.
Import Tiktok constructor from the sdk. Create Tiktok instance.
import { Tiktok } from 'socialX';
const tiktok = new Tiktok({
clientId: '',
clientSecret: '',
});
You'll find clientKey
and clientSecret
from your tiktok application's dashboard.
Methods
tiktok.getAuthorizationLink(_redirectLink)
returns authorization link which you can attach to your login with tiktok button. After successful authorization tiktok will redirect user to the redirect link you provided in function param with authorization code in query params.
tiktok.getUserAccessToken(_authorizationToken)
returns user's access token which is obtained after successful authorization from authorization link above.
tiktok.refreshAccessToken(_refreshToken)
returns user's refreshed access token which is obtained after successful authorization from authorization link above.
tiktok.getUserProfileInfo(_accessToken)
returns user's profile info. Function takes in access token which is obtained using getUserAccessToken function.
tiktok.getUserVideoList(_accessToken, _maxResults?, _sort?)
returns user's latest video list. Function takes in access token which is obtained using getUserAccessToken function.
tiktok.getVideoDetails(_postIdentifiers, _accessToken)
returns user's video details list. Function takes in an array of post identifiers, which can be video ids or video urls.
Create twitter developer account. (https://developer.twitter.com/en/portal/petition/essential/basic-info)
You have to apply for developer account in order to use twitter's api service
Create twitter app. (https://developer.twitter.com/en/portal/projects-and-apps)
Get your bearer token by clicking on key icon. (https://developer.twitter.com/en/portal/projects/{projectId}/apps/{appId}/keys)
Import Twitter constructor from the sdk. Create Twitter instance.
import { Twitter } from 'socialX';
const TwitterBearerToken = 'your app bearer token';
const twitter = new Twitter({ apiToken: TwitterBearerToken });
You'll find token
as Bearer Token from your twitter Projects and Apps selected app tab.
Methods
twitter.getTweetDetails(_tweetId[])
returns returns details and statistics of tweet with engagements and impressions using list of tweet ids, tweet id can be get from url bar of tweet detail page
twitter.getLatestTweets(_username[])
returns list of most recent 10 tweets of users using username, tweets id can be get from url bar of tweet detail page
twitter.getUserDetails(_userName[])
returns list of user details using list of twitter username, tweets id can be get from url bar of tweet detail page
Youtube
Create gmail account.(https://accounts.google.com/signup/v2/webcreateaccount?flowName=GlifWebSignIn&flowEntry=SignUp)
Create project on Google console. (https://console.cloud.google.com/)
Enable youtube v3 apis from. (https://console.cloud.google.com/apis/library/youtube.googleapis.com)
Create Api key for your app integration from. (https://console.cloud.google.com/apis/credentials)
Import youtube constructor from the sdk. Create youtube instance.
import { Youtube } from 'socialX';
const youtubeBearerToken = 'your app api token';
const youtube = new Youtube({ apiToken: youtubeBearerToken });
You'll find token
as Api token from your google console project (https://console.cloud.google.com/apis/credentials).
Methods
youtube.getVideoDetails(_urls[])
returns details of video(s) with engagements and impressions using list of video urls, videos url can be get from url bar of video page
youtube.getLatestVideo(_urls[])
returns list of most recent 10 videos of channel(s) using list of video urls, videos url can be get from url bar of video page
youtube.getChannelDetails(_urls[])
returns list of channel details using array of channel urls in an array, videos url can be get from url bar of video page of youtube