WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] XML-RPC: trying to transition to the new wp.GetPosts

[Resolved] XML-RPC: trying to transition to the new wp.GetPosts

  • 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!

Viewing 1 replies (of 1 total)
  • 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.

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] XML-RPC: trying to transition to the new wp.GetPosts’ is closed to new replies.