How to obtain results for shell-phpcurl asynchronous requests

Source: Internet
Author: User
{Code ...}
Function request ($ url, $ payload) {$ cmd = "curl-x post-H 'content-Type: application/json'"; $ cmd. = "-d '". $ payload. "'". "'". $ url. "'"; if (! $ This-> debug () {$ cmd. = ">/dev/null 2> & 1 &" ;}// send an asynchronous request exec ($ cmd, $ output, $ exit ); return $ exit = 0;}?>

Reply content:
Function request ($ url, $ payload) {$ cmd = "curl-x post-H 'content-Type: application/json'"; $ cmd. = "-d '". $ payload. "'". "'". $ url. "'"; if (! $ This-> debug () {$ cmd. = ">/dev/null 2> & 1 &" ;}// send an asynchronous request exec ($ cmd, $ output, $ exit ); return $ exit = 0;}?>

$a=exec($cmd, $output, $exit);

Why can't you use the php curl function?

Curl should not work, but callback can be called at the request address.
You can use a swoole network framework.

$ Ch = curl_init ();
Curl_setopt ($ ch, CURLOPT_URL, $ url );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ ch, CURLOPT_TIMEOUT, 10 );
$ Response = curl_exec ($ ch );

Swoole can be implemented asynchronously. you can do this synchronously.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.