https://api.laaffic.com/v3/mmsUpload
參數 | 説明 | 是否必填 | 類型 |
---|---|---|---|
fileType | 彩信附件類型,支持:[png,jpg,jpeg,bmp,gif,webp,psd,svg,tiff,mp3,wav,txt,vcf] | 是 | String |
fileData | 彩信文件base64加密傳輸。彩信的發送附件大小上限是50kb,單一任務最多攜帶3份彩信文件(base64編碼轉換可查看該方法最下方JAVA範例代碼) | 是 | String |
Request URL:
https://api.laaffic.com/v3/mmsUpload
Request Method:
POST
Request Headers:
Content-Type: application/json;charset=UTF-8
Sign: 05d7a50893e22a5c4bb3216ae3396c7c
Timestamp: 1630468800
Api-Key: bDqJFiq9
Request Body:
{
"fileType":"txt",
"FileData":"MTizNDU2"
}
Request URL:
https://api.laaffic.com/v3/mmsUpload
Request Method:
POST
Request Headers:
Content-Type: application/json;charset=UTF-8
Sign: 05d7a50893e22a5c4bb3216ae3396c7c
Timestamp: 1630468800
Api-Key: bDqJFiq9
Request Body:
{
"fileType":"png",
"fileData":"Base64 encoded file content"
}
參數 | 説明 | 類型 |
---|---|---|
status | 狀態碼,0成功,其他失敗參見 接口響應碼。 | String |
reason | 失敗原因說明 | String |
data | 上傳附件id,有效期3天,3天內可用於重復發送彩信 | String |
{
"status":"0",
"reason":"success",
"data":"57_3_1727059993381.txt"
}
public static String file2Base64(File file) {
if (file == null) {
return null;
}
String base64 = null;
FileInputStream fin = null;
try {
fin = new FileInputStream(file);
byte[] buff = new byte[fin.available()];
fin.read(buff);
base64 = Base64.encode(buff);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (fin != null) {
try {
fin.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return base64;
}
點擊此處開啟人工服務