* - <EMAILADDRESS> with your email address * - <PASSWORD> with your SmugMug password * * The <APP NAME/VER (URL)> is NOT required, but it's encouraged as it will * allow SmugMug diagnose any issues users may have with your application if * they request help on the SmugMug forums. * * You can see this example in action at http://phpsmug.com/examples/ */ require_once "../phpSmug.php"; try { $f = new phpSmug("APIKey=<API KEY>", "AppName=<APP NAME/VER (URL)>"); // Login With EmailAddress and Password $f->login("EmailAddress=<EMAILADDRESS>", "Password=<PASSWORD>"); // Get list of albums $albums = $f->albums_get(); // Get list of images and other useful information $images = $f->images_get("AlbumID={$albums['0']['id']}", "AlbumKey={$albums['0']['Key']}", "Heavy=1"); $images = $f->APIVer == "1.2.2" ? $images['Images'] : $images; // Display the thumbnails and link to the medium image for each image foreach ($images as $image) { echo '<a href="' . $image['MediumURL'] . '"><img src="' . $image['TinyURL'] . '" title="' . $image['Caption'] . '" alt="' . $image['id'] . '" /></a>'; } } catch (Exception $e) { echo "{$e->getMessage()} (Error Code: {$e->getCode()})"; } ?> </div> </body> </html>
$_SESSION['SmugGalReqToken'] = serialize($d); // Step 2: Get the User to login to SmugMug and Authorise this demo echo "<p>Click <a href='" . $f->authorize() . "' target='_blank'><strong>HERE</strong></a> to Authorize This Demo.</p>"; echo "<p>A new window/tab will open asking you to login to SmugMug (if not already logged in). Once you've logged it, SmugMug will redirect you to a page asking you to approve the access (it's read only) to your public photos. Approve the request and come back to this page and click REFRESH below.</p>"; echo "<p><a href='" . $_SERVER['PHP_SELF'] . "'><strong>REFRESH</strong></a></p>"; } else { $reqToken = unserialize($_SESSION['SmugGalReqToken']); unset($_SESSION['SmugGalReqToken']); // Step 3: Use the Request token obtained in step 1 to get an access token $f->setToken("id={$reqToken['Token']['id']}", "Secret={$reqToken['Token']['Secret']}"); $token = $f->auth_getAccessToken(); // The results of this call is what your application needs to store. // Set the Access token for use by phpSmug. $f->setToken("id={$token['Token']['id']}", "Secret={$token['Token']['Secret']}"); // Get list of public albums $albums = $f->albums_get('Heavy=True'); // Get list of public images and other useful information $images = $f->images_get("AlbumID={$albums['0']['id']}", "AlbumKey={$albums['0']['Key']}", "Heavy=1"); // Display the thumbnails and link to the Album page for each image foreach ($images['Images'] as $image) { echo '<a href="' . $image['URL'] . '"><img src="' . $image['TinyURL'] . '" title="' . $image['Caption'] . '" alt="' . $image['id'] . '" /></a>'; } } } catch (Exception $e) { echo "{$e->getMessage()} (Error Code: {$e->getCode()})"; } ?> </div> </body> </html>
$filesMDUpdated = 0; $filesSkipped = 0; //Begin processing things echo "Determining file structure..."; $structure = get_local_structure($argv[1]); echo "done\n"; try { echo "Connecting to SmugMug..."; $smug = new phpSmug("APIKey={$apiKey}", "AppName={$appInfo}", "APIVer={$apiVersion}"); $smug->login("EmailAddress={$username}", "Password={$password}"); echo "done\n"; echo "Fetching category list from server..."; $categories = $smug->categories_get(); echo "done\n"; echo "Fetching album list from server..."; $serverAlbums = $smug->albums_get("Heavy=1"); echo "done\n"; foreach ($structure as $category => $albums) { echo "\nCategory: {$category}\n"; //Check to see if the category already exists $serverCat = false; foreach ($categories as $cat) { if ($cat['Name'] == $category) { $serverCat = $cat; break; } } //If it doesn't we need to create it if (!$serverCat) { echo "\tCreating category..."; $serverCat['id'] = $smug->categories_create("Name={$category}");
$albumTitle = $argv[1]; $added = 0; $mdUpdated = 0; $replaced = 0; echo "Preparing file information..."; for ($i = 2; $i < count($argv); $i++) { $uploads[] = prepare_file($argv[$i]); } echo "done\n"; try { echo "Connecting to SmugMug..."; $smug = new phpSmug("APIKey={$apiKey}", "AppName={$appInfo}", "APIVer={$apiVersion}"); $smug->login("EmailAddress={$username}", "Password={$password}"); echo "done\n"; echo "Finding album information..."; $albums = $smug->albums_get("Heavy=1"); // Check each album to find the one we want to work on foreach ($albums as $current) { if ($current['Title'] == $albumTitle) { $album = $current; } } if (empty($album)) { echo "Unable to find album information\n"; die; } else { echo "done\n"; } if ($album['ImageCount'] > 0) { echo "Downloading image information from album..."; $albumImages = $smug->images_get("AlbumID={$album['id']}", "AlbumKey={$album['Key']}", "Heavy=1");
<?php /* Last updated with phpSmug 1.0.2 * * This example file shows you how to get a list of public albums for a * particular SmugMug user, using their nickname. * * You'll want to replace: * - <API KEY> with one provided by SmugMug: http://www.smugmug.com/hack/apikeys * - <APP NAME/VER (URL)> with your application name, version and URL * - <NICKNAME> with a SmugMug nickname. * * The <APP NAME/VER (URL)> is NOT required, but it's encouraged as it will * allow SmugMug diagnose any issues users may have with your application if * they request help on the SmugMug forums. */ require_once "phpSmug.php"; $f = new phpSmug("<API KEY>", "<APP NAME/VER (URL)>"); $f->login_anonymously(); $albums = $f->albums_get('<NICKNAME>'); foreach ($albums as $album) { echo $album['Title'] . " (ID: " . $album['id'] . ")<br />"; }
* - <APP NAME/VER (URL)> with your application name, version and URL * - <NICKNAME> with a SmugMug nickname. * * The <APP NAME/VER (URL)> is NOT required, but it's encouraged as it will * allow SmugMug diagnose any issues users may have with your application if * they request help on the SmugMug forums. * * You can see this example in action at http://phpsmug.com/examples/ */ require_once "../phpSmug.php"; try { $f = new phpSmug("APIKey=<API KEY>", "AppName=<APP NAME/VER (URL)>"); // Login Anonymously $f->login(); // Get list of public albums $albums = $f->albums_get('NickName=<NICKNAME>'); // Get list of public images and other useful information $images = $f->images_get("AlbumID={$albums['0']['id']}", "AlbumKey={$albums['0']['Key']}", "Heavy=1"); $images = $f->APIVer == "1.2.2" ? $images['Images'] : $images; // Display the thumbnails and link to the medium image for each image foreach ($images as $image) { echo '<a href="' . $image['MediumURL'] . '"><img src="' . $image['TinyURL'] . '" title="' . $image['Caption'] . '" alt="' . $image['id'] . '" /></a>'; } } catch (Exception $e) { echo "{$e->getMessage()} (Error Code: {$e->getCode()})"; } ?> </div> </body> </html>