文档中心 > Miravia Open Platform

Miravia - Call API with official SDK

更新时间:2022/11/29 访问次数:1038

SDK is automatically generated for your application and includes functions like composing request, generating encryption, response interpretation, message monitoring, and other functions. Using SDK to invoke the APIs is simple and straightforward, and it is recommended to call API with official SDK.

1. Environment requirements

  • JAVA SDK requires Java SE/EE 1.5 or newer version
  • .Net SDK requires .NET Framework 2.0 or newer version (Windows Phone platform not supported)
  • PHP SDK requires PHP 5 or newer version
  • Python requires Python 3.0 or newer version
  • For Ruby, you can install it directly here.

2. Downloading SDK

Before you can download SDK, you need to have registered as a developer and able to login to Miravia Open Platform. The downloaded SDK is associated with the application.

Take the following steps to download SDK for your application:
1. Login Miravia Open Platform and open the APP Console page.
2. Click Manage in the App list to open the App Overview page.
3. In the App Management navigation panel, click SDK Download.
4. Click the Download button to download the SDK for the specific programming language.

3. API sample codes

Take the “/order/get” API as example:


JAVA sample code:

IopClient client = new IopClient(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 sample code

IIopClient client = new IopClient(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 sample code

$c = new IopClient(url,appkey,appSecret);
$request = new IopRequest('/order/get','GET');
$request->addApiParam('order_id','16090');
var_dump($c->execute($request, $accessToken));


Ruby sample code

client = IopApiClient::Client.new(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?
puts response.body

Python sample code

client = iop.IopClient(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)
print(response.body)


Note: Most API methods are called via GET, but some API methods have additional request data sent via POST. Therefore, you need to update your code accordingly. The request type of each API is indicated in the API reference documentation.

FAQ

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