// Check config variables. if (!is_array($groups)) { echo "You must set the '\$groups' variable in config.php\n"; exit(1); } $flickrLatex = new FlickrLatex(__DIR__ . '/data', $apiKey, $apiSecret); // See if we need to authorize. if (!$flickrLatex->authorized()) { $flickrService = $flickrLatex->getService(); // Fetch the request-token. $requestToken = $flickrService->requestRequestToken(); $url = $flickrService->getAuthorizationUri(['oauth_token' => $requestToken->getRequestToken(), 'perms' => 'read']); echo "Please go to this URL to authorize this applicaiton:\n{$url}\n"; // Flickr says, at this point: // "You have successfully authorized the application Flickr Latex to use your credentials. // You should now type this code into the application:" echo "Paste the 9-digit code (with or without hyphens) here: "; $verifier = preg_replace('/[^0-9]/', '', fgets(fopen('php://stdin', 'r'))); // Fetch the access-token, for saving to data/token.json $accessToken = $flickrService->requestAccessToken($requestToken, $verifier, $requestToken->getAccessTokenSecret()); $flickrLatex->setStoredCredentials($accessToken); } if (!$flickrLatex->authorized()) { echo "Unable to authorize. :-("; exit(1); } // Download each group's photos. foreach ($groups as $groupId) { $group = new Group($flickrLatex, $dataDir, __DIR__ . '/templates'); $photoData = $group->download($groupId); }