Difference between revisions of "Disconnect"

From Wordfast Wiki
Jump to: navigation, search
(disconnect)
 
(disconnect)
 
Line 47: Line 47:
 
  data["cmd"] = 25;
 
  data["cmd"] = 25;
 
  var xhr = new XMLHttpRequest();
 
  var xhr = new XMLHttpRequest();
  xhr.open("POST", "www.freetm.com/wfa/api", true);
+
  xhr.open("POST", "anywhere.wordfast.com/wfa/api", true);
 
  xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
 
  xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
 
  xhr.send(JSON.stringify(data));
 
  xhr.send(JSON.stringify(data));
  
 
==== post ====
 
==== post ====
  <form action="www.freetm.com/wfa/api" method="post">
+
  <form action="anywhere.wordfast.com/wfa/api" method="post">
 
     <input type="text" id="key" name="key" value="example@key"/>
 
     <input type="text" id="key" name="key" value="example@key"/>
 
     <input type="text" id="cmd" name="cmd" value="25"/>
 
     <input type="text" id="cmd" name="cmd" value="25"/>
Line 59: Line 59:
  
 
==== get ====
 
==== get ====
www.freetm.com/wfa/api?key=example@key&cmd=25
+
anywhere.wordfast.com/wfa/api?key=example@key&cmd=25
  
 
=== Response example ===
 
=== Response example ===

Latest revision as of 09:39, 17 January 2024

Return to command list

disconnect

disconnect (string key, int cmd)

Disconnect all the TMs and glossaries.

Parameters

key string a valid API Key, generated by making a share at www.freetm.com
cmd int command number is 25

Returned value

connections array Disconnect error by connection if any
id int connection ID
success Boolean result of the command (true or false)
error string error message

Request example

json post with javascript

var data = {};
data["key"] = "example@key";
data["cmd"] = 25;
var xhr = new XMLHttpRequest();
xhr.open("POST", "anywhere.wordfast.com/wfa/api", true);
xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
xhr.send(JSON.stringify(data));

post

<form action="anywhere.wordfast.com/wfa/api" method="post">
   <input type="text" id="key" name="key" value="example@key"/>
   <input type="text" id="cmd" name="cmd" value="25"/>	
   <input type="submit" value="Submit">				
</form>

get

anywhere.wordfast.com/wfa/api?key=example@key&cmd=25

Response example

json

{
   "connections": [
            {
                 "id":      1
                 ,"success": true
                 ,"error":  ""
            }
            ,{
                 "id":      2
                 ,"success": false
                 ,"error":  "unknown error"
            }
            ,{...}
   ]      
}

without white space (new line, carriage return or tabulation).

text

1 : true LF
2 : unknown error LF

LF is a Line feed (new line \u000A)

Remarks

Timeout is 30 seconds