PHP实现file_get_contents发送post请求
2019-04-10
·
via POST on 轻风云
最近按照客户需求写一个支付异步回调通知url的需求,本想用curl写的,后来想想用file_get_contens是否可以实现,果然可以
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
$data = array(
'name' => 'anderyly',
'age' => '19',
'grade' => 'boy',
);
$query = http_build_query($data);
$options['http'] = array(
'timeout' => 60,
'method' => 'POST',
'header' => 'Content-type:application/x-www-form-urlencoded',
'content' => $query
);
$url = "https://blog.aaayun/cc/";
$context = stream_context_create($options);
$result = @file_get_contents($url, false, $context);
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。