Skip to content

Commit

Permalink
Add facebook support
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Apr 19, 2018
1 parent 01e07ed commit 223f898
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/services/facebook.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict'

const cheerio = require('cheerio')
const got = require('got')

module.exports = async username => {
const { body } = await got(`https://mobile.facebook.com/${username}`)
const $ = cheerio.load(body)
return $('meta[property="og:image"]').attr('content')
}

module.exports.supported = {
email: false,
username: true,
domain: false
}
3 changes: 2 additions & 1 deletion src/services/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
const { reduce } = require('lodash')

const services = {
instagram: require('./instagram'),
twitter: require('./twitter'),
instagram: require('./instagram'),
domain: require('./domain'),
github: require('./github'),
facebook: require('./facebook'),
// the services that return defaulta avatar, go after!
gravatar: require('./gravatar')
}
Expand Down
3 changes: 3 additions & 0 deletions static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ <h2>Specifying the service</h2>
<h3>GitHub</h3>
<p><code>&lt;img src="https://unavatar.now.sh/github/:username" /&gt;</code></p>
<p>i.e <a target="_blank" href="https://unavatar.now.sh/github/mdo">https://unavatar.now.sh/github/mdo</a></p>
<h3>Facebook</h3>
<p><code>&lt;img src="https://unavatar.now.sh/facebook/:username" /&gt;</code></p>
<p>i.e <a target="_blank" href="https://unavatar.now.sh/facebook/zuck">https://unavatar.now.sh/facebook/zuck</a></p>
<h3>Gravatar</h3>
<p><code>&lt;img src="https://unavatar.now.sh/gravatar/:email" /&gt;</code></p>
<p>i.e <a target="_blank" href="https://unavatar.now.sh/gravatar/sindresorhus@gmail.com">https://unavatar.now.sh/gravatar/sindresorhus@gmail.com</a></p>
Expand Down

0 comments on commit 223f898

Please sign in to comment.