Solved

Displaying images from Amazon on my website

Posted on 2011-03-24
3
459 Views
Last Modified: 2013-12-25
I'm not too familiar with web design. I want to set up a simple website (offline) that displays random images (one at a time) from the Amazon catolog. Is this to do for free?
0
Comment
Question by:graziazi
  • 2
3 Comments
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 250 total points
ID: 35214526
Where will you get the images?  Do you have permission to use them?  Once you can answer those, you should be able to copy and save the images in your own web site directories.  Getting a random number is a fairly standard feature of most programming languages.  In PHP, I use this code to choose a random image.
// SET THE DEFAULT IMAGE URL
$banner_url   = 'images/florida_beach.jpg';

// CHOOSE A JPG BANNER IMAGE FROM THE BANNERS DIRECTORY
$my_dir = 'banners/';

// OPEN THE BANNERS DIRECTORY
if ($dh = opendir($my_dir))
{
    // MAKE AN ARRAY OF THE JPG IMAGE FILE NAMES
    $b = array();
    while (($filename = readdir($dh)) !== FALSE)
    {
        // CHOOSE ONLY JPG IMAGES
        $file_ext = strtoupper(end(explode('.', $filename)));
        if ($file_ext != 'JPG') continue;
        
        // ELIMINATE ANY FILES THAT START WITH "W"
        if (strtoupper(substr($filename,0,1)) == 'W') continue;
        $b[] = $filename;
    }
    closedir($dh);    
    
    // WITH ALL FILE NAMES IN AN ARRAY, RANDOMIZE THE LIST AND CHOOSE ONE
    shuffle($b);
    $banner_name  = array_pop($b);
    $banner_url   = $my_dir . $banner_name;
    
    // RELEASE THE SHUFFLED ARRAY
    unset($b);
}

Open in new window

0
 

Author Comment

by:graziazi
ID: 35217530
Hi Ray, thanks for that PHP example. I will be using PHP so that will be useful.
I'm not really familiar with the concept of APIs and web services. Even if I had a small number (approx 100) of random images of items I will be happy with that.
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 35220088
OK, I don't know where APIs and web services fit into this equation.  But I am sure that Amazon has millions of images.  The key to success may be whether you have permission to use Amazon's images.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question