• php curl 转为 x-www-form-urlencoded 方式的坑


    网上转变的方法基本都是写添加下面这句:

    curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));

    但加上去后却根本没效果。

    要想以 x-www-form-urlencoded 方式发送,最关键其实是发送的数据格式。

    方式from-data试发送的数据用的是array格式,而方式为 x-www-form-urlencoded 时需要用key=value&key=value的格式发送,发送的是string型的数据。

    from-data数据的为:
    ​​​​​​$data = [
        'name' => 'xiaoming',
        'sex' => 1
    ];
    x-www-form-urlencoded时的数据则要变为
    http_build_query($data);无效的话试试手动key=value&key=value

    原文:https://blog.csdn.net/qq_35641923/article/details/81386708

  • 相关阅读:
    2018.11.12
    2018.11.8
    2018.11.7
    2018.11.6
    2018.11.5
    学习python课程第七天
    作业四.
    学习python课程第六天
    作业3
    学习python课程第五天
  • 原文地址:https://www.cnblogs.com/showcase/p/11732089.html
Copyright © 2020-2023  润新知