Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

282
Visualizações
how to get fbId of any fb page in nodejs

I am trying to get the fbid of our user's profile to generate the fb://page/fbid

below I have attached my function findFacebookId() to get the fbid and it works for all FB page URLs except the URL is in capital form

for example

https://www.facebook.com/userpage - findFacebookId() return the fbId for this url

https://www.facebook.com/UserPage - findFacebookId() will not work for this url

Note: on my local terminal it do not ask to login but when I run this function on my ubuntu server it asks to log in

findFacebookId: (name,cb) => {
    const curl = new (require('curl-request'))();
    return new Promise((resolve, reject) => {
      let url = `https://www.facebook.com/${name}`;
      curl.setHeaders([
        'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36'
      ]).get(url)
        .then(({ statusCode, body, headers }) => {
          var regularExpresionMatch = /fb:\/\/(group|page|profile)\/(\d{1,})/gi;
          const matches = body.match(regularExpresionMatch)
          const oldmatches = body.match(/entity_id":"\d*/i);
          if (matches && matches.length > 0) {
            const id = matches[0];
            cb(null,id);
            return;
          } else {
            cb(true)
          }
        })
        .catch((e) => {
          cb(e);
        });
    });
  }
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda