Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Displaying images from Amazon on my website

Posted on 2011-03-24
3
Medium Priority
?
466 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 111

Accepted Solution

by:
Ray Paseur earned 1000 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 111

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

Threat Trends for MSPs to Watch

See the findings.
Despite its humble beginnings, phishing has come a long way since those first crudely constructed emails. Today, phishing sites can appear and disappear in the length of a coffee break, and it takes more than a little know-how to keep your clients secure.

Question has a verified solution.

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

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
This video teaches users how to migrate an existing Wordpress website to a new domain.
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.
Suggested Courses

885 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