curl posting with header application/x-www-form-urlencoded

后端 未结 3 1805
你的背包
你的背包 2020-12-08 09:55
$post_data=\"dispnumber=567567567&extension=6\";
$url=\"http://xxxxxxxx.xxx/xx/xx\";

I need to post this $post_data using cURL php

3条回答
  •  不知归路
    2020-12-08 10:06

     $curl = curl_init();
     curl_setopt_array($curl, array(
                CURLOPT_URL => "http://example.com",
                CURLOPT_RETURNTRANSFER => true,
                CURLOPT_ENCODING => "",
                CURLOPT_MAXREDIRS => 10,
                CURLOPT_TIMEOUT => 30,
                CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
                CURLOPT_CUSTOMREQUEST => "POST",
                CURLOPT_POSTFIELDS => "value1=111&value2=222",
                CURLOPT_HTTPHEADER => array(
                    "cache-control: no-cache",
                    "content-type: application/x-www-form-urlencoded"
                ),
            ));
     $response = curl_exec($curl);
     $err = curl_error($curl);
    
     curl_close($curl);
    
     if (!$err)
     {
          var_dump($response);
     }
    

提交回复
热议问题