Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const request = require('request');
- class FacebookAPI {
- constructor(access_token, version){
- this.access_token = access_token
- this.version = version
- }
- setAccessToken(access_token){
- this.access_token = access_token
- }
- getAccessToken(){
- return this.access_token
- }
- setVersion(version){
- this.version = version
- }
- getVersion(){
- return this.version
- }
- getNewFeed(user_id){
- request({
- url: `https://graph.facebook.com/${this.version}/${user_id}/feed?access_token=${this.access_token}`,
- }, (err, res, body) => {
- let bd = JSON.parse(body)
- console.log('length: ', bd.data.length)
- console.log(body);
- })
- }
- getDetail(id){
- request({
- //url: `https://graph.facebook.com/${this.version}/${post_id}?access_token=${this.access_token}`
- url: `https://graph.facebook.com/${id}?access_token=${this.access_token}`
- }, (err, res, body) => {
- console.log(body);
- })
- }
- }
- module.exports = FacebookAPI
- let access_token = 'EAAAAUaZA8jlABALYQGdK63tH6gnOClofKBOLr4MWKdJxZCDTE4ADkzItL8AeOGuoa61IzZCVH9Gkw0TKrYsKE1e5Vh16N8sHFWPAr0k1W7ZBeFuNhZBmpw1k7gzDvOXvbA1XrKy2oq41NZCmVcP8f30Ll95vzXfy4v6UzlQ9Ruz9jZCMZCZCPFZCzc'
- let version = 'v1.0'
- let FB = new FacebookAPI(access_token, version)
- FB.getNewFeed('582343342149012');
- console.log("============================***************===========================");
- FB.getDetail('100010276898229');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement