Difference between revisions of "Example Clients"
Line 16: | Line 16: | ||
== Example Clients for Interactive Jobs == | == Example Clients for Interactive Jobs == | ||
− | Below there is a list of example of how to call a service named <tt>SERVICENAME</tt> from different programming languages | + | Below there is a list of example of how to call a service named <tt>SERVICENAME</tt> from different programming languages. |
You'll need to replace <tt>SERVICENAME</tt> with the actual name of the desired service, and adapt the list of parameters in the multipart form to those expected by the service. | You'll need to replace <tt>SERVICENAME</tt> with the actual name of the desired service, and adapt the list of parameters in the multipart form to those expected by the service. | ||
Line 24: | Line 24: | ||
* '''[[PHP Interactive Client|PHP]]''' | * '''[[PHP Interactive Client|PHP]]''' | ||
* '''[[curl Interactive Client|curl]]''' | * '''[[curl Interactive Client|curl]]''' | ||
+ | |||
+ | == Example Clients for Batch Jobs == | ||
+ | |||
+ | Below there is a list of example of how to call a service named <tt>SERVICENAME</tt> from different programming languages. | ||
+ | You'll need to replace <tt>SERVICENAME</tt> with the actual name of the desired service, and adapt the list of parameters in the multipart form to those expected by the service. | ||
+ | |||
+ | These clients send the request and then poll the server to find out when the job is finished, but obviously you can do that at your convenience (e.g. have an independent cron job that polls for all sent requests once every hour, add a trigger in your mail that will launch the retrieval when the "job completed" mail is received, etc.) | ||
+ | |||
+ | * '''[[Python Batch Client|Python]]''' | ||
+ | * '''[[Java Batch Client|Java]]''' | ||
+ | * '''[[Perl Batch Client|Perl]]''' | ||
+ | * '''[[PHP Batch Client|PHP]]''' | ||
+ | * '''[[curl Batch Client|curl]]''' |
Revision as of 13:07, 20 January 2016
To call a TextServer service from a client program running on your side, this client needs to send the appropriate request in the right format.
The request is a standard HTTP POST request with a multiform part containing the same information you would submit via the web interface.
Below you'll find a list of example client programs in different programming languages.
The same code can be used to access any TextServer service with small variations:
- Simply change the service name in the URL to access a different service. You can find out the service name at the top of the "Execute" form of your subscribed services.
- Replace the parameters in the example client with the parametes that the called service requires. Rules are simple:
- Language identification service does not require a "language" parameter, but the other services do.
- All services require a "interactive" parameter stating whether the job is interactive or batch.
- All services require either a "text_input" parameter (for interactive jobs) or a "input_file" parameter (for batch jobs).
- You can find out the name of any other specific parameters for a service in the "Execute" form of your subscribed services.
Example Clients for Interactive Jobs
Below there is a list of example of how to call a service named SERVICENAME from different programming languages. You'll need to replace SERVICENAME with the actual name of the desired service, and adapt the list of parameters in the multipart form to those expected by the service.
Example Clients for Batch Jobs
Below there is a list of example of how to call a service named SERVICENAME from different programming languages. You'll need to replace SERVICENAME with the actual name of the desired service, and adapt the list of parameters in the multipart form to those expected by the service.
These clients send the request and then poll the server to find out when the job is finished, but obviously you can do that at your convenience (e.g. have an independent cron job that polls for all sent requests once every hour, add a trigger in your mail that will launch the retrieval when the "job completed" mail is received, etc.)