[英]PHP | How to POST Request Body?
如何在下一个查询中发布请求?
请求正文:
_username=test%40test.com&_password=1234&_remember_me=true
PHP:
$opts = array('http'=>
array(
'proxy'=>"",
'method'=>"POST",
'header'=>"User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:51.0) Gecko/20100101 Firefox/51.0"
));
$context = stream_context_create($opts);
$result = file_get_contents('https://website.com/login_check', false, $context);
有关更多详细信息,请检查文档
$opts = array(
'http'=>
array(
'proxy' => "",
'method' => "POST",
'content' => '_username=test%40test.com&_password=1234&_remember_me=true',
'header' => "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:51.0) Gecko/20100101 Firefox/51.0"
)
);
$context = stream_context_create($opts);
$result = file_get_contents('https://website.com/login_check', false, $context);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.