Skip to content

sidonaldson/facebook-api-javascript-sdk-get-all-albums-and-photos

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 69.1%
  • HTML 30.9%