PHP and Picasa

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hkipel
Forum Newbie
Posts: 2
Joined: Thu Feb 18, 2010 2:04 pm

PHP and Picasa

Post by hkipel »

Hi everyone! I am a seasoned HTML/css coder just starting to get into PHP coding. Currently, my client is a small business that needed an inventory they could update without my help for their website. I implemented a system with picasa that they could use to update their inventory, however once it was done they wanted more functionality from it. They would like to change one portion of the text description in Picasa to change to red because it's a warning for small children. Additionally, I am using the 'tag' system in picasa for the prices of each item. However they wanted to add more parameters to each item such as weight and item number, but I seem to have run out of variables to use with Picasa. Does anyone have any experience with this that will help me out? Below is the code of my phpfunctions file.

Code: Select all

<?php 
//////////////FUNCTION FOR PULLING ALBUM (CATEGORY) ENTRIES///////////////
function getInventory($userID,$category){
  
    $userid = $userID;
    $album = $category;
    
    $feedURL = "http://picasaweb.google.com/data/feed/api/user/$userid/album/$album";
    
    $sxml = simplexml_load_file($feedURL);
    
    $counts = $sxml->children('http://a9.com/-/spec/opensearchrss/1.0/');
    $total = $counts->totalResults; 
    ?>
    <h1><?php echo $sxml->title; ?></h1>
    <?php echo $total; ?> Item(s) found.
    <p/>
 
    <?php    
    foreach ($sxml->entry as $entry) {
      $title = $entry->title;
      $title = substr("$title", 0, -4);
      $summary = $entry->summary;
      
      $gphoto = $entry->children('http://schemas.google.com/photos/2007');
      $size = $gphoto->size;
      $height = $gphoto->height;
      $width = $gphoto->width;
      $caption = $gphoto->caption;
      
      $media = $entry->children('http://search.yahoo.com/mrss/');
      $thumbnail = $media->group->thumbnail[1];
      $tags = $media->group->keywords;
      $attributes = attributes();
 
      echo "<table class=common width=640><tr><h3>$title</h3></tr>";
      echo "<tr><td width=25%><img src=\"" . 
      $thumbnail->$attributes->{'url'} . "\"/></td>\n";
      echo "<td width=55%><div align=left><span class=\"attr\"><b>Description</span>:</b><br> $summary<br /><br /></div>\n";
      echo "<span class=\"attr\"><b>Price</span>:</b> $$tags </td>";
      echo "<td width=15%><div align=center><span class=\"attr\">";
      echo "<form method=post action=http://emartnet.com/cart/odb/cart.odb>";
      echo "          <b>";
      echo "            <input type=hidden name=UPSContainer value=00 />";
      echo "            <input type=hidden name=cn value='Telephone # Required' />";
      echo "            <input type=hidden name=UPSRateChart value=Regular Daily Pickup />";
      echo "            <input type=hidden name=UPSOpts value=011111111 />";
      echo "            <input type=hidden name=OrigPostal value=07747 />";
      echo "            <input type=hidden name=taxShip value=1 />";
      echo "            <br />";
      echo "            <input type=hidden name=PayPalLogoURL value='images/joelogo2.gif' />";
      echo "            <input type=hidden name=return value=0 />";
      echo "            <input type=hidden name=taxRate1 value='7.0' />";
      echo "            <input type=hidden name=taxRegion1 value='New Jersey' />";
      echo "            <input type=hidden name=bName value='Small Business>";
      echo "            <input type=hidden name=logoUrl value='images/joelogo2.gif' />";
      echo "            <input type=hidden name=PayPalEmail value=email />";
      echo "            <input type=hidden name=cartCfg value=64 />";
      echo "            <input type=hidden name=cn value='Telephone # Required' />";
      echo "            </font></b>";
      echo "          <p><b>Quantity:";
      echo "            <input type=tex name=qty size=3 value=1 />";
      echo "            <br />";
      echo "                <input type=hidden name=taxable value=1 />";
      echo "                <input type=hidden name=product value=\"$title\" />";
      echo "                <input type=hidden name=amount value=\"$tags\" />";
      echo "                <input type=hidden name=Weight value=15 />";
      echo "                   $$tags</b><br />";
      echo "                    <input type=image src=http://emartnet.com/cart/order5Blue.gif border=0 alt='Order This Item' width=70 height=15 name=I1 />";
      echo "                    <br />";
      echo "                    <a href='http://emartnet.com/cart/odb/cart.odb?merchantID=648&logoUrl=images/joelogo2.gif&return=website'> <img src='http://emartnet.com/cart/checkout5Blue.gif' border='0' alt='Check Out Now' width='70' height='15' /></a> </b></font></font></p></form>";
      echo "</td></tr></table><hr>\n";
    };
}
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: PHP and Picasa

Post by pickle »

Sounds like the scope of their project has expanded, and your original solution no longer fits. Your original solution probably wasn't the best (using Picassa), but it likely fit all the requirements they had. As their requirements change, you and your client have to acknowledge the fact that what may have worked in the past may not work for any future expansion they want.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
hkipel
Forum Newbie
Posts: 2
Joined: Thu Feb 18, 2010 2:04 pm

Re: PHP and Picasa

Post by hkipel »

So there is absolutely no way to do even one of the things needed? Such as scanning the description and changing the font color of the phrase?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: PHP and Picasa

Post by pickle »

You could perhaps get the client to agree to doing some sort of BBcode or markup in their tags. For example, if they have an adult toy, they could tag it like:

Code: Select all

toy, plush, [red]Adults only[/red],[weight]2 lbs[/weight],[item]1200945[/item]
You could then use a BBcode parser (or similar markup parser) to determine what to do with the special tags.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply