facebook integration in node.js

const request = require('request-promise');

module.exports = (app) => {

  // you'll need to have requested 'user_about_me' permissions
  // in order to get 'quotes' and 'about' fields from search
  const userFieldSet = 'name, link, is_verified, picture';
  const pageFieldSet = 'name, category, link, picture, is_verified';


  app.post('/facebook-search', (req, res) => {
    const  { queryTerm, searchType } = req.body;

    const options = {
      method: 'GET',
      uri: 'https://graph.facebook.com/search',
      qs: {
        access_token: config.user_access_token,
        q: queryTerm,
        type: searchType,
        fields: searchType === 'page' ? pageFieldSet : userFieldSet
      }
    };

    request(options)
      .then(fbRes => {
// Search results are in the data property of the response.
// There is another property that allows for pagination of results.
// Pagination will not be covered in this post,
// so we only need the data property of the parsed response.
        const parsedRes = JSON.parse(fbRes).data; 
        res.json(parsedRes);
      })
  });
}

3
1
Mighty 90 points

                                    app.get('/facebook-search/:id', (req, res) => {
    
  // you need permission for most of these fields
  const userFieldSet = 'id, name, about, email, accounts, link, is_verified, significant_other, relationship_status, website, picture, photos, feed';
    
  const options = {
    method: 'GET',
    uri: `https://graph.facebook.com/v2.8/${req.params.id}`,
    qs: {
      access_token: user_access_token,
      fields: userFieldSet
    }
  };
  request(options)
    .then(fbRes => {
      res.json(fbRes);
    })
})

3 (1 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
does facebook use node.js facebook api sdks nodejs example facebook integration nodejs facebook login integration using node js node js facebook get started with facebook api nodejs nodejs facebook api how to connect using facebook nodejs api Node JS Facebook API example node.js facebook api example node.js facebook api in my facebook api node.js facebook api nodejs how to integrate facebook with node js node js developer facebook react nodejs express facebook login simple login and login through google and facebook node js how to get the accesstoken on facebook oauth 2.0 express.js how i get accesstoken in oauth2.0 facebook express.js facebook integration with oauth 2.o express.js sign up with facebook usng node js facebook oauth2 nodejs how to make a login with facebook page with node js automatic login with facebook account in node js how to add stay logged in with facebook oauth nodejs nodejs facebook oauth 2.0 facebook node js nodejs facebook authentication implement login with facebook in node js google facebook login and signup passport nodejs como autenticar com facebook typescript nodejs how to authentication with facebook nodejs facebook social sign up express nodejs api social media login facebook api tutorial nodejs admin token facebook api tutorial nodejs login with facebook in node js implement facebook gmail login in my website with passport implement facebook gmail login in my website with passportjs passport facebook auth in node oauth facebook nodejs facebook login with nodejs passport node js use google or facebook access token facebook google pasport registration js react node passport facebook login facebook integration in node js face login nodejs facebook oauth login without sdk nodejs nodejs facebook login facebook api login node js facebook api login for node js node js how to use facebook api login facebook sso with react node and passport facebook login signup with nodejs passport and react node js user aut jwt token with facebook gmail and facebook authentication with node js nodejs login with google and facebook save facebook user profile nodejs save facebook user profile on mongodb nodejs facebook authentication in nodejs facebook login nodejs facebook login with node js facebook login in node js facebook authentication node js login with social media in node js using passportjs how to create login page in node.js using google and facebook login by facebbok node api login by facebook node .js facebook.com for passport js login with social media or manual in express js node js facebook oauth passport how to add facebook auth with npm vues passport js facebook login facebook oauth nodejs vuejs passport facebook login how to use the facebook passport nodejs node jwt token how to and faceboof passportjs nodejs facebook passport callback node facebook login _json.email facebook passport get user profile nodejs how to connect node app with facebook developer fb account password access using node js how to implement facebook api in node js gmail facebook login nodejs mongo db authticate with facebook node express node js facebook login facebook login api nodejs create webhooks in github videojs ima integration for web facebook graph api python example facbook nodejs login sdk facebook integration in node.js
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source