Difference between revisions of "Handprinter API"

From Testiwiki
Jump to: navigation, search
(updated code for API use)
(now it works)
 
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.
 
:''[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 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]].
  
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.
  
<rcode name="app" embed=1 recall_inputs=1 label="Create URL for API" variables="
+
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|
 
name:pw|description:Give the password to enter data|type:default|
 
category:Give data to be entered into the database as a text string.|
 
category:Give data to be entered into the database as a text string.|
Line 15: Line 17:
 
library(OpasnetUtilsExt)
 
library(OpasnetUtilsExt)
  
colnam <- c("Leaf_id", "Name", "Idea", "References")
+
colnam <- c("Leaf_id", "Name", "Idea", "Result")
  
 
set.seed(pw)
 
set.seed(pw)
Line 28: Line 30:
 
oprint(dat)
 
oprint(dat)
  
out <- paste("Handprinter_API?app[inp]=", inp, sep = "")
+
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")
 
olink(out, wiki = "op_en", text = "This URL uploads the data given to the API")
Line 37: Line 39:
 
name = "Handprinter_API",  
 
name = "Handprinter_API",  
 
subset = "Leaves",  
 
subset = "Leaves",  
act_type = "replace",  
+
act_type = "append",  
 
language = "eng",  
 
language = "eng",  
 
who = wiki_username
 
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.

Give data to be entered into the database as a text string.

Give the password to enter data:

Input as a table made into a string:

+ Show code

Show leaves in the database

Show results