我想在wordpress插件中使用php发出http请求,这是我的代码
$request = wp_remote_post('https://en0ctqi09fhu7m.x.pipedream.net/', array(
'headers' => array('Accept' => 'application/json'),
'body' => array('data_type' => 'customer', )
));但在身体里我想发送这些数据
{
"data_type:": "customer",
"customer": {
"id": 123,
"first_name": "John",
"last_name": "Doe",
"email": "john@johndoe.com",
"address": "18/XII, Light Avenue, Upper Manhattan, NY"
}
}我搞不懂如何在身体切片中发送数据
发布于 2021-02-27 20:17:58
试试这个:
$response = wp_remote_post( $url, array(
'method' => 'POST',
'headers' => array('Accept' => 'application/json'),
'timeout' => 45,
'redirection' => 5,
'httpversion' => '1.0',
'blocking' => true,
'body' => array(
'data_type' => 'customer',
'customer' => array(
"id" => 123,
"first_name" => "John",
"last_name" => "Doe",
"email" => "john@johndoe.com",
"address" => "18/XII, Light Avenue, Upper Manhattan, NY"
)
)
));https://stackoverflow.com/questions/66403051
复制相似问题