文档中心 > 淘寶台灣開放平台

API示例代碼

更新时间:2020/06/23 访问次数:514

淘寶台灣開放平台API是基於HTTPS協議呼叫的,因此可以使用具有HTTPS訪問庫的編程語言來呼叫API。您可以直接使用官方SDK或根據淘寶台灣開放平台協議組裝HTTP請求來呼叫API。


使用官方SDK呼叫API
以“/order/get” API舉例,

JAVA示例代碼:

IopClient client = new IopClientImpl(url, appkey, appSecret);
IopRequest request = new IopRequest();
request.setApiName("/order/get");
request.setHttpMethod("GET");
request.addApiParameter("order_id", "16090");
IopResponse response = client.execute(request, accessToken);
System.out.println(response.getBody());
Thread.sleep(10);

NET示例代碼:

IopClient client = new IopClientImpl(url, appkey, appSecret);
IopRequest request = new IopRequest();
request.SetApiName("/order/get");
request.SetHttpMethod("GET");
request.AddApiParameter("order_id", "16090");
IopResponse response = client.Execute(request, accessToken);
Console.WriteLine(response.IsError());
Console.WriteLine(response.Body);

PHP示例代碼:

<?php
    include "../IopSdk.php";
   $c = new IopClientImpl(url, appkey, appSecret);
   $request = new IopRequest('/order/get','GET');
   $request->addApiParam('order_id','16090');
   var_dump($c->execute($request, $accessToken));
?>

Ruby示例代碼:

client = new IopClientImpl(url, appkey, appSecret);
request = IopApiClient::Request.new('/order/get','GET')
request.add_api_parameter("order_id", "16090")
response = client.execute(request, accessToken)
puts response.success?

Python示例代碼:

client = new IopClientImpl(url, appkey, appSecret);
request = iop.IopRequest('/order/get','GET')
request.add_api_param('order_id', '16090')
response = client.execute(request, access_token)
print(response.type)




注意:大多數API是通過GET呼叫的,但是有一些API是通過 POST 發送額外請求數據呼叫的。因此您需要相應地更新您的代碼。每個API的請求類型在API參考文檔中說明。

FAQ

关于此文档暂时还没有FAQ
返回
顶部