我正在尝试将某些文件从wordpress发送到另一台服务器,但是我总是遇到错误 这是我的代码示例:
$path = wp_upload_dir();
$file = @fopen($path['path'] . "/ORDERS.csv", "r");
$file_size = filesize($path['path'] . "/ORDERS.csv");
$file_data = fread($file, $file_size);
$args = array(
'headers' => array('Content-Type' => 'application/json; charset=utf-8'),
'body' => array('Customers' => $file_data, 'Orders' => $file_data, 'Products' => $file_data)
);
$result = wp_remote_post('https://example.com/upload', $args);
$login_token_response = wp_remote_retrieve_body($result);
我总是收到这样的错误
{
"title": "One or more validation errors occurred.",
"status": 400,
"traceId": "|8de9ae17-4a6692f375d9bc1b.",
"errors": {
"Orders": ["'Orders' must not be empty.", "Orders file can't be empty"],
"Products": ["'Products' must not be empty.", "Products file can't be empty"],
"Customers": ["'Customers' must not be empty.", "Customers file can't be empty"]
}
}
就像我在做错什么,任何想法吗?