dalter
Apr-29-2010, 02:58 PM
I am trying to use Colin Seymour's PHP wrapper, phpSmug (http://phpsmug.com/) to write a simple task of searching for the title of an unlisted gallery in order to generate album info and a direct link.
I'm not a professional PHP programmer and everything is working correctly except for searching the array for the title.
Does anyone have any suggestions on how to fix this code?
Thanks,
dalter
==============
<html>
<head>
<title>Album Title Search</title>
</head>
<body>
<?php
require_once("../phpSmug.php");
$hash = "XXXXXXXXXXXXXXXXXXXX.";
$title = "Some Album Title to Search For";
try {
$f = new phpSmug("APIKey=xxxxxxxxxxxxxxx", "AppName=Authorize Access");
$f->login("UserID=xxxxxxx", "PasswordHash=$hash");
$albums = $f->albums_get();
if (in_array(album('Title' => $title), $albums))
{
echo "Album ID: {$album['id']} <br />";
echo "Album Key: {$album['Key']} <br /> ";
echo "Album Title: {$album['Title']} <br /> ";
echo "Category: {$album['Category']['Name']} <br /> ";
echo "<td><a href='http://USERNAME.smugmug.com/". $album['Category']['Name'] . "/" . $album['SubCategory']['Name'] . "/" . $album['id'] . "_" . $album['Key'] ."'>Go To Album</a></td><br /> ";
echo "<br />";
}
else
{
echo "No album found with that name";
}
}
catch (Exception $e) {
echo "{$e->getMessage()} (Error Code: {$e->getCode()})";
}
?>
</body>
</html>
====================
I'm not a professional PHP programmer and everything is working correctly except for searching the array for the title.
Does anyone have any suggestions on how to fix this code?
Thanks,
dalter
==============
<html>
<head>
<title>Album Title Search</title>
</head>
<body>
<?php
require_once("../phpSmug.php");
$hash = "XXXXXXXXXXXXXXXXXXXX.";
$title = "Some Album Title to Search For";
try {
$f = new phpSmug("APIKey=xxxxxxxxxxxxxxx", "AppName=Authorize Access");
$f->login("UserID=xxxxxxx", "PasswordHash=$hash");
$albums = $f->albums_get();
if (in_array(album('Title' => $title), $albums))
{
echo "Album ID: {$album['id']} <br />";
echo "Album Key: {$album['Key']} <br /> ";
echo "Album Title: {$album['Title']} <br /> ";
echo "Category: {$album['Category']['Name']} <br /> ";
echo "<td><a href='http://USERNAME.smugmug.com/". $album['Category']['Name'] . "/" . $album['SubCategory']['Name'] . "/" . $album['id'] . "_" . $album['Key'] ."'>Go To Album</a></td><br /> ";
echo "<br />";
}
else
{
echo "No album found with that name";
}
}
catch (Exception $e) {
echo "{$e->getMessage()} (Error Code: {$e->getCode()})";
}
?>
</body>
</html>
====================