php curl post josn + header

<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);
}

 

posted @ 2019-01-13 20:16  fleam  阅读(243)  评论(0编辑  收藏  举报