美文网首页
guzzle/http post (json)

guzzle/http post (json)

作者: xcyzjs | 来源:发表于2020-05-15 09:48 被阅读0次
    $client   = new \GuzzleHttp\Client();
    $response = $client->post('http://xxx.com/api/login', [
        'json' => [
            'phone'      => "152xxxx1234",
            'password' => "123456",
        ]
    ]);

    $response = $client->post('http://xxx.com/api/login', [
        'form_params' => [
            'phone'      => "152xxxx1234",
            'password' => 123456,
        ]
    ]);

若使用 json, 则 数组中的值(不论是否数字), 都要用 引号 起来, 而 form_params 则不需要

reference

相关文章

网友评论

      本文标题:guzzle/http post (json)

      本文链接:https://www.haomeiwen.com/subject/iymqohtx.html