How does PHP curl send data using post? How the post sends data

Source: Internet
Author: User
What this article brings to you is about how PHP curl uses post to send data? Post to send data methods, there is a certain reference value, the need for friends can refer to, I hope to help you.

What if we are going to send post data? We also need to use curl to help us send the data.

Follow the steps to customize a function with the function name: Post. Post This method requires the passing of two parameters:

1. Requested URL address

2. The data sent

The data sent is an array, which is sent to the specified interface address in the form of a key-value pair, using the Post method.

In the development of the public number when creating a custom menu, you need to use the custom menu interface to the Post method to send custom menu data.

Post's custom function, all the code is as follows:

<?phpfunction Post ($url, $data) {   //early-order init method   $ch = Curl_init ();   Specify URL   curl_setopt ($ch, Curlopt_url, $url);   Set the request to return the result   curl_setopt ($ch, Curlopt_returntransfer, 1);   The declaration uses the POST method to send   curl_setopt ($ch, Curlopt_post, 1);   What data is sent?   curl_setopt ($ch, Curlopt_postfields, $data);   Ignore certificate   curl_setopt ($ch, Curlopt_ssl_verifypeer, false);   curl_setopt ($ch, Curlopt_ssl_verifyhost, false);   Ignore header header information   curl_setopt ($ch, Curlopt_header, 0);   Set timeout time   curl_setopt ($ch, Curlopt_timeout, ten);   Send request   $output = curl_exec ($ch);   Turn off Curl   curl_close ($ch);   Return the data return   $output;}? >

Later in the call public platform or other third-party API system. They need to use the Post method to ask you to send data.
You need to use post to send the data, just need to adjust the post method to do it.

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.