国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

http-client post有問題,請教各位是怎么回事?

veinliu

如題:直接用網(wǎng)上找到PHP代碼測試,接口返回結(jié)果正常,但用http-client post 之后對方?jīng)]有得到數(shù)據(jù);
我要post 的數(shù)據(jù)為:

{"way_code":"001","position":"1","RfidNo":"1000000002"}
function send_post($url, $post_data) {

    //$postdata =  http_build_query($post_data);

    $options = array(

        'http' => array(

            'method' => 'POST',

            'header' => 'Content-type:application/x-www-form-urlencoded',

            'content' => '{"way_code":"001","position":"1","RfidNo":"1000000002"}',

            'timeout' => 15 * 60 // 超時時間(單位:s)

        )

    );

    $context = stream_context_create($options);

    $result = file_get_contents($url, false, $context);

    echo $result;

    return $result;

}
send_post('http://192.168.11.129:2121', $post_data);

這樣返回的結(jié)果正常。

 $post = '{"way_code":"001","position":"1","RfidNo":"1000000002"}';
           // var_dump($post);
            $http = new Workerman\Http\Client();
            $http->post('http://172.50.10.2:7090/facematch/v1/request', $post, function($response){
           // $http->post('http://192.168.11.129:2121',  $post, function($response){
             //   var_dump($response->getStatusCode());
               // var_dump($response->getBody());
                echo $response->getBody();
                return $response->getBody();
            }, function($exception){
                echo $exception;
            });
            這樣POST,從返回的結(jié)果看對方接口好像什么數(shù)據(jù)都沒收到。
            都post到自己的測試接口,http://192.168.11.129:2121
            var_dump $_POST
            結(jié)果是一樣的
            array(1) {
  ["{"way_code":"001","position":"1","RfidNo":"1000000002"}"]=>
  string(0) ""
}

就是沒想明白哪里不對了。

2688 1 0
1個回答

walkor 打賞

v0.1.2 已經(jīng)修復

  • veinliu 2019-12-08

    我怎么升級到v0,1,2

  • veinliu 2019-12-08

    您這個響應速度也太快了點!就是能不能給我點積分,我沒積分不能發(fā)貼和回貼了。

年代過于久遠,無法發(fā)表回答
??