This walkthrough goes through the steps of taking data from Salesforce and then loads that into an existing Socrata table using write. Rforcecom Example from Takekatsu Hiramura
Step 1: Install Required Dependencies
install.packages("RForcecom")
library(RForcecom)
Step 2: Log into Salesforce
To sign in to the Salesforce.com, use rforcecom.login()
function
username <- "yourname@yourcompany.com"
password <- "YourPasswordSECURITY_TOKEN"
instanceURL <- "https://na14.salesforce.com/"
apiVersion <- "26.0"
(session <- rforcecom.login(username, password, instanceURL, apiVersion))
Step 3: Query Salesforce
Make a query using Salesforce Query language (SOQL), not to be confused with the Socrata Query Language (SoQL)..
soqlQuery <- "SELECT Id, Name, Phone FROM Account WHERE AnnualRevenue > 50000 LIMIT 5"
rforcecom.query(session, soqlQuery)
Step 4: Identify Destination Dataset
Ensure that you have a Socrata dataset with proper fields and proper datatypes to write to. Capture the 4x4 ID for the dataset you want to publish to.
Step 5: Write to Your Dataset
socrataEmail <- Sys.getenv("SOCRATA_EMAIL", "XXX@socrata.com")
socrataPassword <- Sys.getenv("SOCRATA_PASSWORD", "XXXXXXX")
datasetToAddToUrl <- "https://opendata.socrata.com/resource/evnp-32vr.json"
write.socrata(table, datasetToAddToUrl, "UPSERT", socrataEmail, socrataPassword)
For full documentation on Rforcecom please see http://rforcecom.plavox.info/.