The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

[resolved] XML-RPC: trying to transition to the new wp.GetPosts (2 posts)

  1. Spinland
    Posted 3 years ago #

    I currently pull the last few posts from my blog using this code:

    $client = new IXR_Client($XMLRPC);
            if (!$client->query('metaWeblog.getRecentPosts',$BLOGID, $USERID,$PASSWORD,$NUMPOSTS)) {
                die('An error occurred - '.$client->getErrorCode().":".$client->getErrorMessage());
            $response = $client->getResponse();

    I recently noticed there are new wp methods introduced, so decided to transition from metaWeblog.getRecentPosts to wp.getPosts. From the Codex it appeared they take the same parameters so I tried simply replacing the call. Unfortunately that didn't work.

    An error occurred - 403:The post type specified is not valid

    I've tried Googling for this, and for a working example of wp.getPosts being used, and have found nothing useful. Is this a simple case of not supplying the correct parameters? A simple example would be most useful.

    Thanks in advance!

  2. Spinland
    Posted 3 years ago #

    Okay, I figured it out. For the optional parameters wp.getPosts wants a struct. I was just passing it an integer in $NUMPOSTS. Assigning the number of posts that I wanted in this manner fixed the error:

    $NUMPOSTS->number = "20";

    Hopefully this helps someone.

Topic Closed

This topic has been closed to new replies.

About this Topic