Solved

Displaying images from Amazon on my website

Posted on 2011-03-24
3
453 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 108

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 108

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
control when hamburger icon kicks in 7 25
How can I split the array as 4 rows per line? 5 64
Angular JS form 8 28
modify h2 4 20
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
These instructions are based on installing Owncloud on your new raspberry pi connected with a usb HDD. What do you need Part A? A Raspberry Pi, model B. A boot SD card for the Raspberry Pi. A usb HDD An Ethernet cable to connect to the lo…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now