Difference between revisions of "Handprinter API"
From Testiwiki
(→Application programming interface (API): quantification removed) |
(updated code for API use) |
||
Line 1: | Line 1: | ||
===Application programming interface (API)=== | ===Application programming interface (API)=== | ||
+ | {{variable}} | ||
+ | :''[http://en.opasnet.org/en-opwiki/index.php?title=Handprinter_API&oldid=31672 Previous version] was designed for the user. This version is designed for an application to enter all parameter values. | ||
The first code on this page is an API that takes in user input and stores that into Opasnet base. The code below is mimicking an application (e.g. in a cell phone) that takes in user input and converts that into an output that can be used as an interface data package between the API and Opasnet. In practice, the application produces an URL that links to this page and contains parameter values for all fields of the API code. | The first code on this page is an API that takes in user input and stores that into Opasnet base. The code below is mimicking an application (e.g. in a cell phone) that takes in user input and converts that into an output that can be used as an interface data package between the API and Opasnet. In practice, the application produces an URL that links to this page and contains parameter values for all fields of the API code. | ||
Line 5: | Line 7: | ||
For more about the URL formatting, see [[R-tools#Giving parameters in an URL]]. | For more about the URL formatting, see [[R-tools#Giving parameters in an URL]]. | ||
− | <rcode name=" | + | <rcode name="app" embed=1 recall_inputs=1 label="Create URL for API" variables=" |
− | name: | + | name:pw|description:Give the password to enter data|type:default| |
− | category: | + | category:Give data to be entered into the database as a text string.| |
− | + | name:inp|description:Input as a table made into a string|type:text | |
− | |||
− | |||
− | |||
− | name: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
"> | "> | ||
library(OpasnetUtils) | library(OpasnetUtils) | ||
library(OpasnetUtilsExt) | library(OpasnetUtilsExt) | ||
− | + | colnam <- c("Leaf_id", "Name", "Idea", "References") | |
− | + | ||
− | + | set.seed(pw) | |
− | + | if(round(runif(1), 6) != 0.921817) stop("Wrong password") | |
− | + | ||
− | + | dat <- strsplit(inp, split = "\\|\\|")[[1]] | |
− | + | dat <- strsplit(dat, split = "\\|") | |
− | + | dat <- as.data.frame(t(as.data.frame(dat))) | |
− | + | colnames(dat) <- colnam | |
− | + | rownames(dat) <- 1:nrow(dat) | |
− | |||
− | ) | ||
oprint(dat) | oprint(dat) | ||
− | out <- paste( | + | out <- paste("Handprinter_API?app[inp]=", inp, sep = "") |
− | + | ||
− | + | olink(out, wiki = "op_en", text = "This URL uploads the data given to the API") | |
− | + | ||
− | + | opbase.upload( | |
− | + | dat, | |
− | + | ident = "Op_en6285", | |
− | + | name = "Handprinter_API", | |
− | + | subset = "Leaves", | |
− | + | act_type = "replace", | |
− | " | + | language = "eng", |
− | + | who = wiki_username | |
) | ) | ||
− | + | ||
</rcode> | </rcode> |
Revision as of 12:55, 6 February 2016
Application programming interface (API)
This page is a variable.
The page identifier is Op_en6285 |
---|
Moderator:Nobody (see all) Click here to sign up. |
Give your opinion to the peer rating of the content of this page. |
Upload data
|
- Previous version was designed for the user. This version is designed for an application to enter all parameter values.
The first code on this page is an API that takes in user input and stores that into Opasnet base. The code below is mimicking an application (e.g. in a cell phone) that takes in user input and converts that into an output that can be used as an interface data package between the API and Opasnet. In practice, the application produces an URL that links to this page and contains parameter values for all fields of the API code.
For more about the URL formatting, see R-tools#Giving parameters in an URL.