wordpress-xmlrpc-client
wordpress-xmlrpc-client copied to clipboard
XML-RPC server accepts POST requests only
In my Laravel project, I want to publish content to WordPress blog. Everything works very well except for uploading media files. When I upload the file up to 850 KB, the file uploaded successfully. But when the file size exceeds 850 KB I get this error message XML-RPC server accepts POST requests only. And in my opinion this is unthinkable because I am using the same function to upload a file and the request method is always POST. This is my code.
$endpoint = $item->wp_url . '/xmlrpc.php';
$wpUser = $item->wp_username;
$wpPass = $item->wp_password;
$wpClient = new \HieuLe\WordpressXmlrpcClient\WordpressClient();
$wpClient->setCredentials($endpoint, $wpUser, $wpPass);
ob_clean();
$headers = get_headers($file->refe_file_path, TRUE);
$mimType = $headers['Content-Type'];
$output = '';
$handle = fopen($file->s3_file_path, 'r');
if ($handle) {
while (!feof($handle)) {
$output .= fread($handle, 1048576);
}
fclose($handle);
}
$uploadMedia = $wpClient->uploadFile($file->real_file_name, $mimType, $output, false);
$attachmentId = $uploadMedia['attachment_id'];
$content = [
'post_type' => 'post',
'post_status' => $request->input('post_status'),
'post_title' => $title,
'post_excerpt' => $request->input('post_excerpt'),
'post_content' => $request->input('post_content'),
'post_format' => $request->input('post_format'),
'post_thumbnail' => $attachmentId,
'terms_names' => [
'category' => $request->input('post_category'),
'post_tag' => $request->input('post_tags'),
],
'post_author' => $request->input('post_author'),
];```
@letrunghieu Hey, are there any possibilities to install or activate the plugin using XML RPC service?