文档

访问TPP服务

更新时间:

域名

访问TPP服务的地址。

  • VPC域名,可以在用户购买实例时,选择的VPC访问。

  • 公网域名,暂不支持。

image

HTTP GET访问

http://${domain}/recommend?_input_charset=UTF-8&_output_charset=UTF-8&_instance_cluster=${instanceId}&appid=${sceneId}&userId=&yourRequestParam=

shell curl

curl -i "http://${domain}/recommend?_input_charset=UTF-8&_output_charset=UTF-8&_instance_cluster=${instanceId}&appid=${sceneId}&yourRequestParam="

Java

OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()
  .url("http://${domain}/recommend?_input_charset=UTF-8&_output_charset=UTF-8&_instance_cluster=${instanceId}&appid=${sceneId}&yourRequestParam=")
  .method("GET",null)
  .addHeader("Content-Type", "application/x-www-form-urlencoded")
  .build();
Response response = client.newCall(request).execute();

JS

var myHeaders = new Headers();

var urlencoded = new URLSearchParams();

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  body: urlencoded};

fetch("http://${domain}/recommend?_input_charset=UTF-8&_output_charset=UTF-8&_instance_cluster=${instanceId}&appid=${sceneId}&yourRequestParam=", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

HTTP POST访问

  • url

http://${domain}/recommend?

  • header

"Content-Type:application/x-www-form-urlencoded"

  • body

_instance_cluster=${instanceId}&appid=${sceneId}

shell curl

curl --location --request POST 'http://${domain}/recommend' \
--header 'Content-Type: application/x-www-form-urlencoded' \

--data-urlencode '_input_charset=UTF-8' \
--data-urlencode '_output_charset=UTF-8' \
--data-urlencode '_instance_cluster=${instanceId}' \
--data-urlencode 'appid=${sceneId}' \
--data-urlencode 'yourRequestParam=${yourRequestParam}'

Java

OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "_input_charset=UTF-8&_output_charset=UTF-8&_instance_cluster=${instanceId}&appid=${sceneId}&yourRequestParam=${yourRequestParam}");
Request request = new Request.Builder()
  .url("http://${domain}/recommend?")
  .method("POST", body)
  .addHeader("Content-Type", "application/x-www-form-urlencoded")
  .build();
Response response = client.newCall(request).execute();

JS

var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");

var urlencoded = new URLSearchParams();
urlencoded.append("_input_charset", "UTF-8");
urlencoded.append("_output_charset", "UTF-8");
urlencoded.append("_instance_cluster", "${instanceId}");
urlencoded.append("appid", "${sceneId}");
urlencoded.append("yourRequestParam", "${yourRequestParam}");

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: urlencoded,
  redirect: 'follow'
};

fetch("http://${domain}/recommend", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));