1. 传参格式 json
)
{
();
);
);
);
//https
);
);
// post数据
);
// post设置头
// curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:8080');//设置代理服务器
);
// post的变量
$arr = json_encode($array,);
);
);
);
{
);
}
);
//打印获得的数据
);
}
2. body体字符串式 表单传参 数组
)
{
//方法1 自己拼接
$body = "key=val&key1=val2";
//方法 2
//或用 $data = ['key' => 'val', 'key1' => 'val1'] ;$body = http_build_query($data) ;构建返回一个 URL 编码后的字符串
();
);
);
);
);
);
{
);
}
);
//打印获得的数据
);
}