-
-
Save Binvnhehe999/c3fa21deeaf5d3666829f499edc4e85f to your computer and use it in GitHub Desktop.
Downloading all images from a imgur gallery with a simple PHP Script.
This file contains 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
<?php | |
// ID of gallery, you get it from URL. | |
$galleryId = 'nuAM3'; | |
$url = 'http://imgur.com/ajaxalbums/getimages/'.$galleryId.'/hit.json?all=true'; | |
$jsonContent = file_get_contents($url); | |
$data = json_decode($jsonContent, true); | |
if(!is_dir('images_'.$galleryId)) { | |
mkdir('images_'.$galleryId); | |
} | |
foreach($data['data']['images'] as $image) { | |
$name = $image['hash'].$image['ext']; | |
$imageContent = file_get_contents('http://i.imgur.com/'.$name); | |
file_put_contents('images_'.$galleryId.'/'.$name, $imageContent); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment