Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8690995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:01:46+00:00 2026-06-13T00:01:46+00:00

I need to call a webservice from a PHP script. The web service is

  • 0

I need to call a webservice from a PHP script. The web service is slow, and I’m not interested in its response, I only want to send data to it.

I’m trying to use curl_multi_exec (following an example here: http://www.jaisenmathai.com/articles/php-curl-asynchronous.html), and it’s second parameter ($still_running) lets you know when its done sending AND receiving. But, again, I’m only interested in knowing when my script is done sending. Of course, if I exit the script before its done sending the data, the web service never registers receiving the request.

Another way to look at it is to detect when PHP is idle, waiting for a response from the server.

What I’d like to achieve is this dialogue:

  • PHP: Hi, please save this data
  • WS: Ok, ho hum, lets think about this.
  • PHP: Cya! (off to do something more important)
  • WS: Ok, Im done processing, here is your response… PHP? Where did you go? I feel used 🙁
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T00:01:48+00:00Added an answer on June 13, 2026 at 12:01 am

    You can try

    $url = "http://localhost/server.php";
    $nodes = array();
    $nodes["A"] = array("data" => mt_rand());   <-------- Random Data 
    $nodes["B"] = array("data" => mt_rand());
    $nodes["C"] = array("data" => mt_rand());
    $nodes["D"] = array("data" => mt_rand());
    
        echo "<pre>";
    $mh = curl_multi_init();
    $curl_array = array();
    foreach ( $nodes as $i => $data ) {
        $curl_array[$i] = curl_init($url);
        curl_setopt($curl_array[$i], CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl_array[$i], CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 (.NET CLR 3.5.30729)');
        curl_setopt($curl_array[$i], CURLOPT_POST, true);
        curl_setopt($curl_array[$i], CURLOPT_POSTFIELDS, $data);
        curl_setopt($curl_array[$i], CURLOPT_CONNECTTIMEOUT, 5);
        curl_setopt($curl_array[$i], CURLOPT_TIMEOUT, 15);
        curl_multi_add_handle($mh, $curl_array[$i]);
        echo "Please save this data  No : $i ", $data['data'], PHP_EOL;
    }
    
    echo PHP_EOL ,PHP_EOL;
    
    $running = NULL;
    do {
        usleep(10000);
        curl_multi_exec($mh, $running);
    } while ( $running > 0 );
    $res = array();
    foreach ( $nodes as $i => $url ) {
        $curlErrorCode = curl_errno($curl_array[$i]);
        if ($curlErrorCode === 0) {
            $info = curl_getinfo($curl_array[$i]);
            if ($info['http_code'] == 200) { <------- Connection OK
                echo "Cya! (off to do something more important  No : $i Done", PHP_EOL;
                echo curl_multi_getcontent($curl_array[$i]) , PHP_EOL ;
            }
        }
        curl_multi_remove_handle($mh, $curl_array[$i]);
        curl_close($curl_array[$i]);
    }
    curl_multi_close($mh);
    

    Output

    Please save this data  No : A 1130087324
    Please save this data  No : B 1780371600
    Please save this data  No : C 764866719
    Please save this data  No : D 2042666801
    
    
    Cya! (off to do something more important  No : A Done
    Ok, Im done processing, here is your response... 
        {"data":"1130087324"} PHP? Where did you go? 
        I feel used :(
    113
    Cya! (off to do something more important  No : B Done
    Ok, Im done processing, here is your response... 
        {"data":"1780371600"} PHP? Where did you go? 
        I feel used :(
    113
    Cya! (off to do something more important  No : C Done
    Ok, Im done processing, here is your response... 
        {"data":"764866719"} PHP? Where did you go? 
        I feel used :(
    112
    Cya! (off to do something more important  No : D Done
    Ok, Im done processing, here is your response... 
        {"data":"2042666801"} PHP? Where did you go? 
        I feel used :(
    113
    

    Simple Test Server server.php

    echo printf("Ok, Im done processing, here is your response... \n\t%s PHP? Where did you go? \n\tI feel used :(\n", json_encode($_REQUEST));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to call a web service from jQuery, when I put the breakpoint
I want to get the header information from a webservice call. That service returns
In an Activity, I need to call a web service every 30 seconds or
I have a synchronous web service call that returns a message. I need to
I writing a PHP script program under Linux. In the script, I need call
I need to call a method from a webservice, so I've written this code:
I need to call a webmethod of a webservice asynchronously from code behind of
Currently i am consuming web service from android by the method SOAP.Here i need
I need to access a webservice from Java. The service has a WSDL .
I have a webservice (From other company) witch I need to call and use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.