Handprinter API: Difference between revisions
Jump to navigation
Jump to search
(→Application programming interface (API): quantification removed) |
(now it works) |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
===Application programming interface (API)=== | ===Application programming interface (API)=== | ||
:''[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. | |||
For more about the URL formatting, see [[R-tools#Giving parameters in an URL]]. | The code on this page uploads leaf suggestions to Handprinter database. In addition, it produces a URL link that contains the data given, and so it shows how the same data can be uploaded using an application external to Opasnet. For more about the URL formatting, see [[R-tools#Giving parameters in an URL]]. | ||
<rcode name=" | The input is a table where the columns are separated by "|" and rows are separated by "||". The test version has four columns: Leaf_id, Name, Idea, and Result. | ||
name: | |||
category: | You must know the password to make the code actually work. At this testing phase, it is 72634524. | ||
<rcode name="app" embed=1 recall_inputs=1 label="Upload data" variables=" | |||
name:pw|description:Give the password to enter data|type:default| | |||
category:Give data to be entered into the database as a text string.| | |||
name: | name:inp|description:Input as a table made into a string|type:text | ||
"> | "> | ||
library(OpasnetUtils) | library(OpasnetUtils) | ||
library(OpasnetUtilsExt) | library(OpasnetUtilsExt) | ||
colnam <- c("Leaf_id", "Name", "Idea", "Result") | |||
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[pw]=00000000&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 = "append", | |||
" | language = "eng", | ||
who = wiki_username | |||
) | ) | ||
</rcode> | </rcode> | ||
=== Show leaves in the database === | |||
{{resultlink}} |
Latest revision as of 14:53, 6 February 2016
Application programming interface (API)
- Previous version was designed for the user. This version is designed for an application to enter all parameter values.
The code on this page uploads leaf suggestions to Handprinter database. In addition, it produces a URL link that contains the data given, and so it shows how the same data can be uploaded using an application external to Opasnet. For more about the URL formatting, see R-tools#Giving parameters in an URL.
The input is a table where the columns are separated by "|" and rows are separated by "||". The test version has four columns: Leaf_id, Name, Idea, and Result.
You must know the password to make the code actually work. At this testing phase, it is 72634524.
Show leaves in the database
{{#opasnet_base_link:Op_en6285}}