From af2f0588eeaf15473b2d0bdfd167576bd5a02244 Mon Sep 17 00:00:00 2001 From: fengyuexingzi Date: Sat, 28 Oct 2017 11:00:08 +0800 Subject: [PATCH] 'curl' --- curl.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 curl.php diff --git a/curl.php b/curl.php new file mode 100644 index 0000000..f71f0d0 --- /dev/null +++ b/curl.php @@ -0,0 +1,33 @@ + 'king', + 'pwd' => '123456' +]; +$data = http_build_query($data); + +$ch = curl_init(); +curl_setopt($ch, CURLOPT_URL, $url); +curl_setopt($ch, CURLOPT_HEADER, false); +curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); +curl_setopt($ch, CURLOPT_HTTPHEADER, [ + 'Content-Type: application/json;charset=utf-8', +]); +curl_setopt($ch, CURLOPT_POST, true); +curl_setopt($ch, CURLOPT_POSTFIELDS, $data); +$result = curl_exec($ch); +if ($result === false) { + echo 'curlError: ' . curl_error($ch); +} else { + echo $result; +} +curl_close($ch); \ No newline at end of file