The image with return results of “mediaId” needs to be displayedwith the tag, and here’s the following method:
Download interface with file to get the file content, and the spliced URL can be used directly in the label
<img src="https://openplatform-xxxx.com/media/download?access_token=app_52890e21fbdd408894912802b78095c5&media_id=$iwHSAADx6woAC9IAAOlzAqNqcGcDBgTRAtAF0QYYBrBuEhqOrAsA2sBFsQKLqzIdBwAIAAmiaW0 " />
Please note: This address is temporarybecause it cannot be accessed after the validity period of “access_token” expired.
Get image address
Interface name
Interface address
GET https://开放平台网关域名/media/download?access_token=ACCESS_TOKEN&media_id=xxxx
参数说明
Parameter | Whether it’s required to fill in | Remark |
---|---|---|
access_token | Yes | The appToken required to access the gateway |
media_id | Yes | The mediaId returned by the service after the upload is complete |
Back Remark
Go back to the file stream. Please note: this interface is only used to get the content of the file, and it does not contain the original name of the file
Note: You need to subscribe to /media/download service of gateway first to use this interface. Service type: file storage
Getting application “access_token”
Interface name
Interface address
GET https://开放平台网关域名/gettoken.json
Parameter description
Parameter | Parameter Type | Must | Remark |
---|---|---|---|
appkey | String | Yes | App ak |
appsecret | String | Yes | App ak |
SDK request example (JAVA):
ExecutableClient executableClient =ExecutableClient.getInstance();
executableClient.setAccessKey("appkey");
executableClient.setSecretKey("appsecrt");
executableClient.setDomainName("不同环境对应不同域名");
executableClient.setProtocal("https");
executableClient.init();
//executableClient要单例,并且使用前要初始化,只需要初始化一次
String api = "/gettoken.json";
GetClient getClient = executableClient.newGetClient(api);
//设置参数
getClient.addParameter("appkey", "37affba10137489c9cc8812b6b19590000003501");
getClient.addParameter("appsecret", "37affba10137489c9cc8812b6b19590000003501");
//调用API
String apiResult = getClient.get();
System.out.println(apiResult);
Back remark
Parameter | Remark |
---|---|
accessToken | App access_token |
expiresIn | expiration time, unit (seconds) |
{
"success":true,
"content":{
"data":{
"accessToken":"c139fe44362f41b6b84862ec82ab84d9",
"expiresIn":"7200"
},
"requestId":"df04428415724925400701038d663a",
"responseMessage":"OK",
"responseCode":"0",
"success": true
}
}