MultiAvatar - a nice way to fetch avatars
This library allows you to get user avatar URLs from various social-networks without diving into their APIs.
Supported providers
'FacebookUserID'
'GoogleUserID'
'TwitterUsername' // without '@', e.g. 'IGN' or 'pcgamer'
- Vkontakte
'VkID'
Installation
npm install multi-avatar
How to fetch user avatar URL
Some services forces us to make a API-requests. This is why library uses Promises (any-promise) and URLs caching. (Caching works only if you use the same instance of AvatarProvider between avatar requests)
; // ES7// orvar multiAvatar = FacebookAvatarProvider = multiAvatarFacebookAvatarProvider GoogleAvatarProvider = multiAvatarGoogleAvatarProvider; // Basic using: // ID should be always a string, because it can be larger, than Number.MAX_VALUE ; // Fetching multiple avatars from different providers ; // Fetching several sizes of avatar // Note "s" at the end ; // Fetching several sizes of avatar from several providers ; // Error handling: ;
NOTE: only google and vk can return null, because they depends on JSON-request, so we can determine, that user is not exists. Other providers just return broken image or something like that.
Contribute
- Fork it!
- Create new branch:
git checkout -b my-new-feature
- Commit changes:
git commit -m 'Add new feature'
- Push it:
git push origin my-new-feature
- Submit a pull request!