Curl post request function

WBOY
Release: 2016-07-25 09:02:09
Original
1147 people have browsed it
/**3 * PHP Crul library simulates Post submission to Alipay gateway 4 * If you use Crul, you need to change the settings of your php.ini file, find php_curl.dll and remove the ";" in front of it. 5 * return $data 6*/ 7 function post($gateway,$req_data) { 8 $ch = curl_init(); 9 curl_setopt($ch, CURLOPT_URL, $gateway); //Configure the gateway address 10 curl_setopt($ch, CURLOPT_HEADER, 0); //Filter HTTP header 11 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 12 curl_setopt($ch, CURLOPT_POST, 1); //Set post submission 13 curl_setopt($ch, CURLOPT_POSTFIELDS, $req_data); //post transfer data 14 $data = curl_exec($ch); 15 curl_close($ch); 16 return $data; 17}
  1. /**
  2. 3 * PHP Crul library simulates Post submission to Alipay gateway
  3. 4 * If you use Crul, you need to change the settings of your php.ini file, find php_curl.dll and remove the ";" in front of it
  4. 5 * Return to $data
  5. 6*/
  6. 7 function post($gateway,$req_data) {
  7. 8 $ch = curl_init();
  8. 9 curl_setopt($ch, CURLOPT_URL, $gateway); //Configure gateway Address
  9. 10 curl_setopt($ch, CURLOPT_HEADER, 0); //Filter
  10. HTTP header
  11. 11 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  12. 12 curl_setopt($ch, CURLOPT_POST, 1); //Set up post submission
  13. 13 curl_setopt($ch, CURLOPT_POSTFIELDS, $req_data); //post transfer data
  14. 14 $data = curl_exec($ch);
  15. 15 curl_close($ch);
  16. 16 return $data;
  17. 17 }
Copy code


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!