Skip to content

Instantly share code, notes, and snippets.

@azpat
Created September 19, 2013 02:27
Show Gist options
  • Select an option

  • Save azpat/6618418 to your computer and use it in GitHub Desktop.

Select an option

Save azpat/6618418 to your computer and use it in GitHub Desktop.
Get-FacebookPictures.ps1
#First, Get an Access Token from here: https://developers.facebook.com/tools/explorer
# More info here: http://stackoverflow.com/questions/4219580/is-it-possible-to-download-all-of-my-photos-on-facebook-through-facebook-graph-a
# See Also: https://github.com/mhowsden/get_albums.py
# Assumes C:\temp\facebookpics exists - this version doesn't make or check or anything fancy like that.
$accesstoken="YOURACCESSTOKENGOESHERE"
$response = Invoke-WebRequest -Uri "https://graph.facebook.com/me/albums?access_token=$accesstoken"
if ($response.StatusCode -ne 200){Write-Error "Failed to connect to FaceBook Graph API"}
else{
$data = convertfrom-json $response.Content
$albums = $data.data
$i=0;
foreach ($album in $albums)
{
$response2 = Invoke-WebRequest -Uri "https://graph.facebook.com/$($album.id)/photos?access_token=$accesstoken"
if ($response2.StatusCode -ne 200){Write-Error "Failed to connect to FaceBook Graph API"}
$data2 = convertfrom-json $response2.Content
$images = $data2.data.source
foreach ($image in $images)
{
Invoke-WebRequest -Uri $image -OutFile "C:\temp\facebookpics\$i.jpg";
$i++;
}
}
}
@Cirzen

Cirzen commented Feb 26, 2016

Copy link
Copy Markdown

Thank you, this helped solved a head-scratcher I'd been struggling with!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment