Skip to content

Commit

Permalink
Merge pull request #463 from pasocon1993/master
Browse files Browse the repository at this point in the history
指定短信编码格式
  • Loading branch information
sxci authored Dec 9, 2019
2 parents 2d92265 + 3da429b commit 1baa257
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/main/java/com/qiniu/sms/SmsManager.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.qiniu.sms;

import com.qiniu.common.Constants;
import com.qiniu.common.QiniuException;
import com.qiniu.http.Client;
import com.qiniu.http.MethodType;
Expand Down Expand Up @@ -68,7 +69,7 @@ public Response sendMessage(String templateId, String[] mobiles, Map<String, Str
bodyMap.put("template_id", templateId);
bodyMap.put("mobiles", mobiles);
bodyMap.put("parameters", parameters);
return post(requestUrl, Json.encode(bodyMap).getBytes());
return post(requestUrl, Json.encode(bodyMap).getBytes(Constants.UTF_8));
}

/**
Expand All @@ -85,7 +86,7 @@ public Response sendSingleMessage(String templateId, String mobile, Map<String,
bodyMap.put("template_id", templateId);
bodyMap.put("mobile", mobile);
bodyMap.put("parameters", parameters);
return post(requestUrl, Json.encode(bodyMap).getBytes());
return post(requestUrl, Json.encode(bodyMap).getBytes(Constants.UTF_8));
}

/**
Expand All @@ -102,7 +103,7 @@ public Response sendOverseaMessage(String templateId, String mobile, Map<String,
bodyMap.put("template_id", templateId);
bodyMap.put("mobile", mobile);
bodyMap.put("parameters", parameters);
return post(requestUrl, Json.encode(bodyMap).getBytes());
return post(requestUrl, Json.encode(bodyMap).getBytes(Constants.UTF_8));
}

/**
Expand All @@ -117,7 +118,7 @@ public Response sendFulltextMessage(String[] mobiles, String content) throws Qin
StringMap bodyMap = new StringMap();
bodyMap.put("mobiles", mobiles);
bodyMap.put("content", content);
return post(requestUrl, Json.encode(bodyMap).getBytes());
return post(requestUrl, Json.encode(bodyMap).getBytes(Constants.UTF_8));
}

/**
Expand Down Expand Up @@ -164,7 +165,7 @@ public Response createSignature(String signature, String source, String[] pics)
bodyMap.put("signature", signature);
bodyMap.put("source", source);
bodyMap.putWhen("pics", pics, pics.length > 0);
return post(requestUrl, Json.encode(bodyMap).getBytes());
return post(requestUrl, Json.encode(bodyMap).getBytes(Constants.UTF_8));
}

/**
Expand All @@ -177,7 +178,7 @@ public Response modifySignature(String signatureId, String signature) throws Qin
String reqUrl = String.format("%s/v1/signature/%s", configuration.smsHost(), signatureId);
StringMap bodyMap = new StringMap();
bodyMap.put("signature", signature);
return put(reqUrl, Json.encode(bodyMap).getBytes());
return put(reqUrl, Json.encode(bodyMap).getBytes(Constants.UTF_8));
}

/**
Expand Down Expand Up @@ -233,7 +234,7 @@ public Response createTemplate(String name, String template, String type, String
bodyMap.put("type", type);
bodyMap.put("description", description);
bodyMap.put("signature_id", signatureId);
return post(requestUrl, Json.encode(bodyMap).getBytes());
return post(requestUrl, Json.encode(bodyMap).getBytes(Constants.UTF_8));
}

/**
Expand All @@ -253,7 +254,7 @@ public Response modifyTemplate(String templateId, String name, String template,
bodyMap.put("template", template);
bodyMap.put("description", description);
bodyMap.put("signature_id", signatureId);
return put(requestUrl, Json.encode(bodyMap).getBytes());
return put(requestUrl, Json.encode(bodyMap).getBytes(Constants.UTF_8));
}

/**
Expand Down

0 comments on commit 1baa257

Please sign in to comment.