Skip to content
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Initial commit Aug 1, 2018
LICENSE
README.md
fb-albums.html Convert spaces to tabs all files Oct 7, 2018
fb-code.js Fix typo change falsy to truthy Oct 26, 2018
fb-photos.html
index.html
script.js Convert spaces to tabs all files Oct 7, 2018

README.md

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.

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

Just Using the Functions

I made this in demo form for anyone to quickly get things workings. But if you'd like to just use the functions, then all you need is fb-code.js. You can obviously also use it as a starting point and edit each function to suit your needs. As shown in the tutorial, this will all be stored in an object called fbAlbumsPhotosObj. Additionally it'll be the response of winCallback for each function.

Constructor

new FbAllPhotos()

getAlbums()

function getAlbums(int limitAlbums = 25, function winCallback(obj response), function failCallback(string error))

Description

Get Facebook albums

Parameters

  • limitAlbums - The amount of albums to fetch at once
  • winCallback(response) - On success
  • failCallback(error) - On failure

getPhotosInAlbum()

function getPhotosInAlbum(int|string albumId, int limitPics = 10, function winCallback(obj response), function failCallback(string error))

Description

Get Facebook photos in an album

Parameters

  • albumId - The album id to get photos from. Should just be int, but Facebook API returns the album id as a string
  • limitAlbums - The amount of photos to fetch at once
  • winCallback(response) - On success
  • failCallback(error) - On failure

getMoreAlbums()

function getMoreAlbums(function winCallback(obj response), function failCallback(string error))

Description

Get more Facebook albums until depletion

Parameters

  • winCallback(response) - On success
  • failCallback(error) - On failure

getMorePhotosInAlbum()

function getMorePhotosInAlbum(int|string albumId, function winCallback(obj response), function failCallback(string error))

Description

Get more Facebook photos in album until depletion

Parameters

  • albumId - The album id to get photos from. Should just be int, but Facebook API returns the album id as a string
  • winCallback(response) - On success
  • failCallback(error) - On failure
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.