Abhishek Yadav
Abhishek Yadav

Reputation: 1

how to call a URL in background using PHP

I want to call a 3rd party URL, this URL is given to me by my SMS portal which is used to send SMS to end users.
Now the problem is that when I call this URL through PHP the state changes and I'm redirected to that page, is there any method by which we can call this URL again and again, the reason I want to call the URL so many times is because there can be 1000 users so in the URL I have to mention the name of the user and there phone number.
This process should be asynchronous.

Upvotes: 0

Views: 2589

Answers (3)

Ranty
Ranty

Reputation: 3362

You can make another script that will send the request and you can then run it from your main script with a shell command by appending & or | at now at the end of the command to move the process in to background.

Upvotes: 0

Alain
Alain

Reputation: 36984

What about exec() ?

Something like:

$code = escapeshellarg("file_get_contents('http://www.site.com/etc...');");
exec("php -r {$code} > /dev/null 2>&1 &");

More info about those arguments.

Upvotes: 1

user7282
user7282

Reputation: 5196

use CURL .See http://php.net/manual/en/book.curl.php for more details

Upvotes: 0

Related Questions