Created
September 19, 2013 02:27
-
-
Save azpat/6618418 to your computer and use it in GitHub Desktop.
Get-FacebookPictures.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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++; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you, this helped solved a head-scratcher I'd been struggling with!