GET及POST请求header和body
POST请求
/**
* POST 请求
* json $paramJson body数据
* string $url 链接
* array $headers_array header数据
* return json
* */
function fetchPost($url, $paramJson, $headers_array = [], $accessToken = '') {
ini_set('user_agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.1901.183');
$headers = [
// "Accept" => "*/*",
// "Content-Type" => "application/json;charset=UTF-8",
];
if (count($headers_array) > 0) {
$headers = array_merge($headers, $headers_array);
}
$header_str = "";
foreach ($headers as $header_key => $header_value) {
$header_str .= $header_key. ": ". $header_value ."\r\n";
}
$opts = array('
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20