0

I've been creating a php script for downloading facebook user data. Because there are a lot of data, script works about 1- 1,5 minut, before it ends. Hovewer after couple of seconds my app on Facebook appears error, suppose because there are no response from my server.

But I want to proceed app, for ask some questions for user, so how can I put that downloading process into the background.

Some part of my app which is downloading the data from Facebook is located in different server, and I send them only access token and user ID, and after successful authorization it starts to download data.

For send data to the different server I used file_get_contents() method.

EDIT: I think about something like that: put process on the server into the background, and in the user-part script kill the method which began that downloading script.

Ziemo
  • 941
  • 8
  • 27

1 Answers1

0

So there is some answer which I discovered and you don't need to use cron. In my project I used AJAX like this:

function loadXMLDoc()
    {
    var xmlhttp;
    if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
    }
    else
    {// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlhttp.open("POST","[YOUR_PHP_FILE.php]",true);
    xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlhttp.send("[REQUEST TO THE SERVER]");
    }

So that request goes in to the "background" and even if client reload or change the page it still working and (in the case of my project) it analyzes data without interruption into the end.

Ziemo
  • 941
  • 8
  • 27