1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Is this even possible?

Discussion in 'General Programming Chat' started by Freddyjames, Dec 3, 2012.

  1. Freddyjames

    Freddyjames Senior Member

    Joined:
    Jul 4, 2011
    Messages:
    825
    Likes Received:
    1,471
    I have a site that gives a "boost" to a popular online browser game. Each page I set up generates a set of time-stamped links to click which gives the "boost" to the player through facebook.

    The question is - is it possible for those links to get "clicked" automatically every 8 hours?

    This is the Java I use on each page that generates the links:

    Code:
    <script type="text/javascript">
    <!--
    var d = new Date()
    
    month=(d.getUTCMonth()+1).toString();
    if(month.length<2) month = "0" + month;
    
    day=(d.getUTCDate()).toString();
    if(day.length<2) day = "0" + day;
    
    hour=(d.getUTCHours()).toString();
    if(hour.length<2) hour = "0" + hour;
    
    minute=(d.getUTCMinutes()).toString();
    if(minute.length<2) minute = "0" + minute;
    
    for (x=1 ; x<=10 ; x++)
    {
        xx = x.toString();    
        if (xx.length<2) xx = "0" + xx;
        
        h= "http://xxxxxxxxxxxxxxx/xxxxxxxxxxxx/facebook.xxxxxxxxxx.php?F=xxxxxxxxxxxxxxxxx=" + d.getUTCFullYear() + "." + month + "." + day + "+" + hour + "." + minute + "." + xx + "xxxxxxxxxxxxxxxxxx";
        document.writeln("<p>"+("Link "+x).link(h)+"</p>");";
        document.writeln("<p>"+("Link "+x).link(h)+"</p>");
    }
    //-->
    </script>
    What I want to do, is have each link auto-clicked every 8 hours, or at least auto-clicked when someone goes to the page itself.

    Many thanks in advance for any help or advice.
     
    Last edited: Dec 3, 2012
  2. Berkeli

    Berkeli Regular Member

    Joined:
    Oct 16, 2012
    Messages:
    352
    Likes Received:
    216
    Occupation:
    SEO
    Location:
    Above & Beyond
    Home Page:
    the page will only run the script when it's visited, so there's no chance you gonna be able to do it automatic with client side js.
    either php to run the script or server side js
    i noticed it's not a function so it must run every time you visit a page
     
    • Thanks Thanks x 1
  3. Mr Stark

    Mr Stark Regular Member

    Joined:
    Mar 11, 2012
    Messages:
    202
    Likes Received:
    170
    Location:
    Stark Industries
    Set a cron job on your server...
     
    • Thanks Thanks x 1
  4. Freddyjames

    Freddyjames Senior Member

    Joined:
    Jul 4, 2011
    Messages:
    825
    Likes Received:
    1,471
    What is a "cron job" bud? I've never heard of it before.
     
  5. cgimaster

    cgimaster Power Member

    Joined:
    Jun 30, 2012
    Messages:
    525
    Likes Received:
    311
    Gender:
    Male
    if you set a timeout to rerun and let the page open and load it might work but untested just an idea.

    You might need to make it on an iframe or _blank page not sure if that would work.
     
    • Thanks Thanks x 1
  6. cgimaster

    cgimaster Power Member

    Joined:
    Jun 30, 2012
    Messages:
    525
    Likes Received:
    311
    Gender:
    Male
    Cron is a time-based job scheduler that is available on all *nix server, if your host have cpanel you mostly have the option on your panel.

    You could also use google's scheduler API to make it call your page or w/e.
     
    • Thanks Thanks x 1
  7. Freddyjames

    Freddyjames Senior Member

    Joined:
    Jul 4, 2011
    Messages:
    825
    Likes Received:
    1,471
    Doesn't look like my host has cpanel.

    I do not mind if the code has to be re-written in another language - but the links must have an individual time stamp in them.

    So which option is best?
     
  8. browsing_hosts

    browsing_hosts Regular Member

    Joined:
    Nov 12, 2010
    Messages:
    360
    Likes Received:
    341
    Occupation:
    Student at Uni + IM on side
    Location:
    London
    Put the link into a batch file and run the exe server side with time release coding for automated function calls.
     
    • Thanks Thanks x 1
  9. Freddyjames

    Freddyjames Senior Member

    Joined:
    Jul 4, 2011
    Messages:
    825
    Likes Received:
    1,471
    Ok thanks bud. I am a total noob at this sort of thing however - any pointers on where I could go to learn how to do that?
     
  10. Blackberry_11

    Blackberry_11 Regular Member

    Joined:
    Apr 17, 2011
    Messages:
    266
    Likes Received:
    19
    Game but it's an applate ,
    please take help from youtube and "thenewboston".
     
  11. AshBash13

    AshBash13 Newbie

    Joined:
    Dec 20, 2012
    Messages:
    15
    Likes Received:
    0
    thenewboston is great. highly recommended