Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can RWordPress retrieve blog post content?

Tags:

r

xml

wordpress

I would like to retrieve the content of posts from my WordPress blog. Using the package RWordPress it is straightforward to retrieve categories and tags and titles, but what about the content of posts?

# Download and load the package
if (!require('RWordPress')) {
    devtools::install_github(c("duncantl/XMLRPC", "duncantl/RWordPress"))
  }

library(RWordPress)

# list all the functions in the package
lsf.str("package:RWordPress")

Here, for example, is the code to obtain categories, with my specifics redacted in brackets:

Cat <- getCategoryList(login = c([my user name] = '[my password'),
        .server = 'http://[my blog on].wpengine.com/xmlrpc.php')

The linked SO question is not applicable as it doesn't use RWordPress [HTML and CSS and PHP coding].

This site is about posting on WordPress, not retrieving from WordPress [publishing, not gettting]. Another question uses xmlrpc as does RWordPress and a getPosts call, but it does not rely on R.

Posts <- getPosts(num = 100, blogid = 0L, login = c([my user name] = '[my password]'), .server = 'http://[my blog name].wpengine.com/xmlrpc.php')

The above code returns dates and titles and status, but not content.

Thank you for any guidance.

******************* Edit after first answer

After requiring RWordPress and XMLRPC, and then defining an object for login and for the .server, here is the console message:

> getPageList(blogid = 0L, login = WordpressLogin, .server = WordpressURL)
Error in xml.rpc(.server, op, as.integer(blogid), names(login), as.character(login),  : 
  Problems

I find that "Problems" is not an informative error message for me.

like image 535
lawyeR Avatar asked Oct 14 '16 00:10

lawyeR


People also ask

How do I restore a WordPress blog post?

Log into your WordPress admin panel and go to Pages or Posts (Depending on which one you want to restore). Click on Trash and you'll be redirected to all your deleted pages and posts. Select the page you want to restore, and two options will appear under it – Restore and Delete Permanently.

How do I recover a blog post?

To restore a blog: Sign in to Blogger. At the top left, under "Trashed blogs," click the blog you want to restore. Undelete.

How do I recover an unsaved WordPress post?

If the post was created on the dashboard of your own blog at Dashboard > Posts > All Posts > Add New then you ought to be able to recover a lost post or page from revisions if needs be. If you cannot locate a revision or restore from Trash then the content has been lost and cannot be recovered.

How do I restore contents of a page in WordPress?

In your WordPress admin dashboard, go to Pages > All Pages. Look for the Trash tab storing all the pages that have been deleted during the last 30 days. Hover your mouse over the deleted page you'd like to recover. Click “Restore.”


1 Answers

Tell me if I am missing something, but for me the description identifier of posts seem to deliver the whole text.

RWordpress maps all the functions in XML-RPC wp

if (!require('RWordPress')) {
  devtools::install_github(c("duncantl/XMLRPC", "duncantl/RWordPress"))
}
library(RWordPress)
options(WordpressLogin = c(myusername = 'mypassword'),
        WordpressURL = 'http://localhost/myblog/wordpress/xmlrpc.php')
# library(knitr)

# can refer this page
# http://codex.wordpress.org/XML-RPC_wp

#Rwordpress has a one to one mapping 
getCategories()

#get a list of pages
getPageList()
# pick one id from above list 
id=27
getPage(pageid = id)
# description seems to have all the text of post, even though the 
# document is sparse
getPage(pageid = id)$description

#similarly for posts
getPost(postid = 6)$description

I am of course using a locally installed blog, but I'd reckon this should work remotely.

like image 80
R.S. Avatar answered Oct 20 '22 16:10

R.S.