dimanche 24 janvier 2016

Random image generator from Imgur album

I'm looking to create an Apache site using PHP so that each time a person directs to it, it will grab a random image from a previously created Imgur album full of images and display the image onload without ever leaving the website. I am thinking I would need to use the Imgur API to make this sort of thing with php but I don't know where to start. Does anybody know how I may be able to do this?

I made this javascript alternative using arrays but this only fetches images listed in the javascript code, I would like to make use of the Imgur API and automatically fetch all the images' URLs from the Imgur album and randomly pick one to display every time the user loads the webpage.

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Random</title>

<script type="text/javascript">
function randomlinks(){
    var myrandom=Math.round(Math.random()*263)
    var links=new Array()
links[0]="http://ift.tt/1ZLDy9Y"


    window.location=links[myrandom]

}
</script>

  </head>
  <body onload="randomlinks()">

  </body>
</html>




Aucun commentaire:

Enregistrer un commentaire