复制curl --request GET \
--url 'http://apis.haoservice.com/efficient/TranslateLanguage?content=我爱你,同学们&fromto=zh&to=en&key=your_AppKey'
复制http GET 'http://apis.haoservice.com/efficient/TranslateLanguage?content=我爱你,同学们&fromto=zh&to=en&key=your_AppKey'
复制wget --quiet \
--method GET \
--output-document \
- 'http://apis.haoservice.com/efficient/TranslateLanguage?content=我爱你,同学们&fromto=zh&to=en&key=your_AppKey'
复制var unirest = require("unirest");
var req = unirest("GET", "http://apis.haoservice.com/efficient/TranslateLanguage");
req.query({
'content':我爱你,同学们,'fromto':zh,'to':en,"key": "your_AppKey"
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
复制var http = require("http");
var options = {
"method": "GET",
"hostname": "apis.haoservice.com",
"port": null,
"path": "?content=我爱你,同学们&fromto=zh&to=en&key=your_AppKey",
"headers": {}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
复制var request = require("request");
var options = { method: 'GET',
url: 'http://apis.haoservice.com/efficient/TranslateLanguage',
qs:
{
content:我爱你,同学们,fromto:zh,to:en, key: 'your_AppKey' } };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
复制HttpResponse response = Unirest.get("http://apis.haoservice.com/efficient/TranslateLanguage?content=我爱你,同学们&fromto=zh&to=en&key=your_AppKey")
.asString();
复制OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("http://apis.haoservice.com/efficient/TranslateLanguage?content=我爱你,同学们&fromto=zh&to=en&key=your_AppKey")
.get()
.build();
Response response = client.newCall(request).execute();
复制import requests
url = "http://apis.haoservice.com/efficient/TranslateLanguage"
response = requests.request("GET", url)
print(response.text)
复制import http.client
conn = http.client.HTTPConnection("apis.haoservice.com")
conn.request("GET", "?content=我爱你,同学们&fromto=zh&to=en&key=your_AppKey")
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
复制<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://apis.haoservice.com/efficient/TranslateLanguage?content=我爱你,同学们&fromto=zh&to=en&key=your_AppKey",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
复制<?php
$request = new HttpRequest();
$request->setUrl('http://apis.haoservice.com/efficient/TranslateLanguage');
$request->setMethod(HTTP_METH_GET);
$request->setQueryData(array(
'content' => 我爱你,同学们,'fromto' => zh,'to' => en, 'key' => 'your_AppKey'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
复制<?php
$client = new http\Client;
$request = new http\Client\Request;
$request->setRequestUrl('http://apis.haoservice.com/efficient/TranslateLanguage');
$request->setRequestMethod('GET');
$request->setQuery(new http\QueryString(array(
'content' => 我爱你,同学们,'fromto' => zh,'to' => en, 'key' => 'your_AppKey'
)));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
复制require 'uri'
require 'net/http'
url = URI("http://apis.haoservice.com/efficient/TranslateLanguage?content=我爱你,同学们&fromto=zh&to=en&key=your_AppKey")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
复制#import
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://apis.haoservice.com/efficient/TranslateLanguage?content=我爱你,同学们&fromto=zh&to=en&key=your_AppKey"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
复制package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "http://apis.haoservice.com/efficient/TranslateLanguage?content=我爱你,同学们&fromto=zh&to=en&key=your_AppKey"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
复制import Foundation
var request = NSMutableURLRequest(URL: NSURL(string: "http://apis.haoservice.com/efficient/TranslateLanguage?content=我爱你,同学们&fromto=zh&to=en&key=your_AppKey")!,
cachePolicy: .UseProtocolCachePolicy,
timeoutInterval: 10.0)
request.HTTPMethod = "GET"
let session = NSURLSession.sharedSession()
let dataTask = session.dataTaskWithRequest(request, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
println(error)
} else {
let httpResponse = response as? NSHTTPURLResponse
println(httpResponse)
}
})
dataTask.resume()
复制var settings = {
"async": true,
"crossDomain": true,
"url": "http://apis.haoservice.com/efficient/TranslateLanguage?content=我爱你,同学们&fromto=zh&to=en&key=your_AppKey",
"method": "GET",
"headers": {}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
复制var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("GET", "http://apis.haoservice.com/efficient/TranslateLanguage?content=我爱你,同学们&fromto=zh&to=en&key=your_AppKey");
xhr.send(data);
复制var client = new RestClient("http://apis.haoservice.com/efficient/TranslateLanguage?content=我爱你,同学们&fromto=zh&to=en&key=your_AppKey");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
复制open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "http://apis.haoservice.com/efficient/TranslateLanguage?content=我爱你,同学们&fromto=zh&to=en&key=your_AppKey" in
Client.call `GET uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
复制CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "http://apis.haoservice.com/efficient/TranslateLanguage?content=我爱你,同学们&fromto=zh&to=en&key=your_AppKey");
CURLcode ret = curl_easy_perform(hnd);