Nikz Nikz - 8 months ago 107
PHP Question

PHP execute a external url without redirect (background)

I have a API url for sending SMS and I have to execute this url once i create a new user. Using PHP how can i call the url in background?
I have tried


My url is like this

While using
im getting a 'Bad request' due to the change in url where all the '&' got replaced using '
'. this replaces the username and password which passed to the url.

And also tried some other functions like
. unfortunately for all this function im facing the same issue.

So which is the proper method for calling this kinda URL.?
thanks in advance.


Perhaps try executing it like so:

$url = '';

$fields = array(
    'username'      => "hidden",
    'password'      => "hidden",
    'sendername'    => "iZycon",
    'mobileno'      => 8443223

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));

//execute post
$result = curl_exec($ch);

//close connection