Login to WordPress using RCurl Login to WordPress using RCurl wordpress wordpress

Login to WordPress using RCurl


I've dealt with something similar using REDCap - might be useful for you too. This short example shows how I used the REDCap API to grab data.

library(RCurl)out <- postForm("https://redcap.url.org/redcap/api/",                 token="INSERT TOKEN HERE",                 content="record",                 type="flat",                 format="csv",                 .opts=curlOptions(ssl.verifypeer=FALSE))write(out,file="C:/wherever/out.csv")

Note that this doesn't do proper checking for SSL - I've improved that in later versions. The more lengthy explanation is on my Google+ profile: https://plus.google.com/106259574970597769926/posts/U3fVCTV4EdQ

It looks like you can use cURL to log into Wordpress by passing the right parameters, as described here:http://w4dev.com/wp/login-into-wp-using-curl/

It looks like the URL in question is http://localhost/wordpress/wp-login.php and the parameters that matter can be found at the page above. Basically, you need to define the user, their password, and where you want to redirect them to on the site afterwards. These are how the parameters are described in that PHP example

"log=". $login_user ."&pwd=" . $login_pass ."&wp-submit=Log%20In&redirect_to=" . $visit_url;

Basically, it's just constructing a string to post, which looks something like:

http://yourwordpress.fake/wp-login.php?log=trehman&pwd=abc123456&wp-submit=Log%20In&redirect_to=http://yourwordpress.fake/pageyouwant

So, you could just change the postForm above to have a different URL and parameters, and it should get you authenticated and then redirect you to the page you want. I'm not an expert here, but I'm pretty sure that you can redirect to another long URL with parameters, which would let you "submit" a form or something similar.


You can use the XMLRPC package to access wordpress

library(XMLRPC)service <- "http://myblog.wordpress.com/xmlrpc.php"xml.rpc(service, "wp.getUsersBlogs", "my@email", "secretpassword", .convert = TRUE)

The functions supported by this API are documented here. Using wp.uploadFile it might be possible to load photos into the server.