Security News
OpenJS: “XZ Utils Cyberattack Likely Not an Isolated Incident”
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.
facebook-javascript-all-photos
Advanced tools
Weekly downloads
Readme
A simple demo of how to use the Facebook API with the JavaScript SDK to get all of your albums and photos. Luckily the Cordova Facebook plugin is pretty similar to it also.
A full writeup can be found here https://websitebeaver.com/facebook-api-javascript-sdk-get-all-albums-and-photos, along with a demo video.
npm install facebook-javascript-all-photos
Import
import FbAllPhotos from 'facebook-javascript-all-photos';
git clone https://github.com/WebsiteBeaver/facebook-javascript-all-photos.git
Import
import FbAllPhotos from 'facebook-javascript-all-photos/src/fb-code.js';
Firstly, you must get approved by approved by Facebook to use user_photos
permissions.
Once you're aproved, you just need to change the appId
property on FB.init()
, which is located in index.html.
FB.init({
appId : ENTER APP ID HERE,
autoLogAppEvents : true,
xfbml : true,
version : 'v3.0'
});
Class to simplify getting all Facebook albums and photos and albums using Facebook API.
Kind: global class
Properties
Name | Type | Description |
---|---|---|
fullObj | object | Full object of Facebook albums, photos and pagination. |
errorObj | object | Facebook-specific error object. |
profilePictureURL | string | Facebook profile picture URL. |
Create empty object.
Example
const fbAllPhotos = new FbAllPhotos();
Get Facebook profile picture.
Kind: instance method of FbAllPhotos
Fulfil: string
- The url of the Facebook profile picture.
Reject: Error
- Rejected promise with message.
Example
fbAllPhotos.getProfilePicture()
.then(profilePictureURL => { console.log(profilePictureURL); })
.catch(errorMsg => {
if(errorMsg === 'fbError') {
console.log(fbAllPhotos.errorObj.message);
} else if(errorMsg === 'noProfilePicture') {
console.log('No profile picture');
}
});
Get Facebook albums.
Kind: instance method of FbAllPhotos
Fulfil: object
- The full Facebook albums and photos object.
Reject: Error
- Rejected promise with message.
Param | Type | Default | Description |
---|---|---|---|
[limitAlbums] | int | 25 | The number of albums to retrieve. |
Example
fbAllPhotos.getAlbums(15)
.then(fullObj => { console.log(fullObj); })
.catch(errorMsg => {
if(errorMsg === 'fbError') {
console.log(fbAllPhotos.errorObj.message);
} else if(errorMsg === 'noAlbums') {
console.log('No albums');
}
});
Get Facebook photos in a specified album.
Kind: instance method of FbAllPhotos
Fulfil: object
- Object with only specified album and its photos.
Reject: Error
- Rejected promise with message.
Param | Type | Default | Description |
---|---|---|---|
albumId | int | The album id to get photos from. | |
[limitPhotos] | int | 25 | The number of photos in an album to retrieve. |
Example
const albumId = 8395830308572754;
fbAllPhotos.getPhotosInAlbum(albumId, 15)
.then(albumObj => { console.log(albumObj); })
.catch(errorMsg => {
if(errorMsg === 'fbError') {
console.log(fbAllPhotos.errorObj.message);
} else if(errorMsg === 'noAlbum') {
console.log('Album does not exist');
} else if(errorMsg === 'noPhotos') {
console.log('No photos in album');
}
});
Get more Facebook albums.
Kind: instance method of FbAllPhotos
Fulfil: object
- The full Facebook albums and photos object.
Reject: Error
- Rejected promise with message.
Example
fbAllPhotos.getMoreAlbums()
.then(fullObj => { console.log(fullObj); })
.catch(errorMsg => {
if(errorMsg === 'fbError') {
console.log(fbAllPhotos.errorObj.message); //Error message from Facebook
} else if(errorMsg === 'serverError') {
console.log(fbAllPhotos.errorObj); //Fetch API response object
} else if(errorMsg === 'noMore') {
console.log('No more albums to retrieve');
}
});
Get more Facebook photos in a specified album.
Kind: instance method of FbAllPhotos
Fulfil: object
- Object with only specified album and its photos.
Reject: Error
- Rejected promise with message.
Param | Type | Description |
---|---|---|
albumId | int | The album id to get more photos from. |
Example
const albumId = 8395830308572754;
fbAllPhotos.getMorePhotosInAlbum(albumId)
.then(albumObj => { console.log(albumObj); })
.catch(errorMsg => {
if(errorMsg === 'fbError') {
console.log(fbAllPhotos.errorObj.message); //Error message from Facebook
} else if(errorMsg === 'serverError') {
console.log(fbAllPhotos.errorObj); //Fetch API response object
} else if(errorMsg === 'noAlbum') {
console.log('Album does not exist');
} else if(errorMsg === 'noMore') {
console.log('No more photos in album to retrieve');
}
});
FAQs
Get all Facebook albums and photos https://websitebeaver.com/facebook-api-javascript-sdk-get-all-albums-and-photos
The npm package facebook-javascript-all-photos receives a total of 222 weekly downloads. As such, facebook-javascript-all-photos popularity was classified as not popular.
We found that facebook-javascript-all-photos demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.
Company News
Come meet the Socket team at BSidesSF and RSA! We're sponsoring several fun networking events and we would love to see you there.
Security News
OSI is starting a conversation aimed at removing the excuse of the SaaS loophole for companies navigating licensing and the complexities of doing business with open source.