php curl post josn + header
阿新 • • 發佈:2019-01-13
<meta charset="utf8"> <?php ini_set("max_execution_time",1800000); $array = array( '123123'); $i = 0; foreach ($array as $k=>$v){ $i++; echo "<br>".$i."<br>"; $params = array('logisticsNo'=>$v); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"http://localhost:9080" ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt($ch, CURLOPT_POST, 1 ); curl_setopt($ch, CURLOPT_POSTFIELDS,json_encode($params)); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json','token:123123')); $return = curl_exec($ch); var_dump($return); }