wp_xmlrpc_server::blogger_getPost() WordPress Method

The wp_xmlrpc_server::blogger_getPost() method is used to retrieve a post from a WordPress blog. This method can be used by applications that support the Blogger API to interface with WordPress.

wp_xmlrpc_server::blogger_getPost( array $args ) #

Retrieve post.


Parameters

$args

(array)(Required)Method arguments. Note: arguments must be ordered as documented.

  • 'blog_id'
    (int) (unused)
  • 'post_ID'
    (int)
  • 'username'
    (string)
  • 'password'
    (string)


Top ↑

Return

(array|IXR_Error)


Top ↑

Source

File: wp-includes/class-wp-xmlrpc-server.php

	public function blogger_getPost( $args ) {
		$this->escape( $args );

		$post_ID  = (int) $args[1];
		$username = $args[2];
		$password = $args[3];

		$user = $this->login( $username, $password );
		if ( ! $user ) {
			return $this->error;
		}

		$post_data = get_post( $post_ID, ARRAY_A );
		if ( ! $post_data ) {
			return new IXR_Error( 404, __( 'Invalid post ID.' ) );
		}

		if ( ! current_user_can( 'edit_post', $post_ID ) ) {
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
		}

		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
		do_action( 'xmlrpc_call', 'blogger.getPost', $args, $this );

		$categories = implode( ',', wp_get_post_categories( $post_ID ) );

		$content  = '<title>' . wp_unslash( $post_data['post_title'] ) . '</title>';
		$content .= '<category>' . $categories . '</category>';
		$content .= wp_unslash( $post_data['post_content'] );

		$struct = array(
			'userid'      => $post_data['post_author'],
			'dateCreated' => $this->_convert_date( $post_data['post_date'] ),
			'content'     => $content,
			'postid'      => (string) $post_data['ID'],
		);

		return $struct;
	}


Top ↑

Changelog

Changelog
VersionDescription
1.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More