Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML-RPC server accepts POST requests only #49

Open
sanasar-dev opened this issue Mar 8, 2021 · 1 comment
Open

XML-RPC server accepts POST requests only #49

sanasar-dev opened this issue Mar 8, 2021 · 1 comment

Comments

@sanasar-dev
Copy link

sanasar-dev commented Mar 8, 2021

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'),
];```
@mayanksdudakiya
Copy link

@letrunghieu Hey, are there any possibilities to install or activate the plugin using XML RPC service?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants