npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

facebook-javascript-all-photos

v1.0.3

Published

Get all Facebook albums and photos https://websitebeaver.com/facebook-api-javascript-sdk-get-all-albums-and-photos

Downloads

366

Readme

Facebook API JavaScript SDK get all Albums and Photos

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.

Install

NPM

npm install facebook-javascript-all-photos

Import

import FbAllPhotos from 'facebook-javascript-all-photos';

Git

git clone https://github.com/WebsiteBeaver/facebook-javascript-all-photos.git

Import

import FbAllPhotos from 'facebook-javascript-all-photos/src/fb-code.js';

How to Use?

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'
});

FbAllPhotos

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. |

new FbAllPhotos()

Create empty object.

Example

const fbAllPhotos = new FbAllPhotos();

fbAllPhotos.getProfilePicture()

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');
    }
  });

fbAllPhotos.getAlbums([limitAlbums])

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');
    }
  });

fbAllPhotos.getPhotosInAlbum(albumId, [limitPhotos])

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');
    }
  });

fbAllPhotos.getMoreAlbums()

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');
    }
  });

fbAllPhotos.getMorePhotosInAlbum(albumId)

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');
    }
  });