Solved

Displaying images from Amazon on my website

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

The task of choosing a web design company to build a website for your business should never be taken in a light manner. Provided the fact that your website will act as a representative to your business and will be responsible for imposing an online …
Online collaboration is quickly becoming embedded in the workplace, and its benefits are tangible. See what the current landscape looks like and what the future holds for collaboration tools and the future of work.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

911 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

20 Experts available now in Live!

Get 1:1 Help Now