How to asynchrously POST a HTTP request?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • seaside

    How to asynchrously POST a HTTP request?

    I need to POST a HTTP request from within a PHP app, to inform another
    app regarding certain changes.

    Since I don't need to get an answer back, I'd like to fire-and-forget
    the POST request asynchronously.

    An option might be to create a new PHP process, forward my data to the
    new instance and continue execution in the main one.

    Are there other options? Options, which don't require to interact with
    the OS directly?

  • Benjamin

    #2
    Re: How to asynchrously POST a HTTP request?


    seaside wrote:
    I need to POST a HTTP request from within a PHP app, to inform another
    app regarding certain changes.
    >
    Since I don't need to get an answer back, I'd like to fire-and-forget
    the POST request asynchronously.
    >
    An option might be to create a new PHP process, forward my data to the
    new instance and continue execution in the main one.
    no, you don't need to do this
    >
    Are there other options? Options, which don't require to interact with
    the OS directly?
    you can use the cURL PHP extension to do this really easily
    here's an example:
    $curl = curl_init("http ://www.mypostapp.c om/blah/foo");
    curl_setopt(CUR OPT_POST, true);
    curl_setopt(CUR OPT_POSTFIELDS, $mypost);
    curl_exec($curl );
    curl_close($cur l);

    Comment

    • seaside

      #3
      Re: How to asynchrously POST a HTTP request?


      Benjamin schrieb:
      seaside wrote:
      I need to POST a HTTP request from within a PHP app, to inform another
      app regarding certain changes.

      Since I don't need to get an answer back, I'd like to fire-and-forget
      the POST request asynchronously.
      >
      you can use the cURL PHP extension to do this really easily
      here's an example:
      $curl = curl_init("http ://www.mypostapp.c om/blah/foo");
      curl_setopt(CUR OPT_POST, true);
      curl_setopt(CUR OPT_POSTFIELDS, $mypost);
      curl_exec($curl );
      curl_close($cur l);
      Thx! Really helpful!

      Comment

      Working...