forked from qiniu/java-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
203 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,44 @@ | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import com.qiniu.common.QiniuException; | ||
import com.qiniu.http.Response; | ||
import com.qiniu.sms.SmsManager; | ||
import com.qiniu.util.Auth; | ||
|
||
public class SendMessageDemo { | ||
public static void main(String args[]) { | ||
//设置需要操作的账号的AK和SK | ||
String ACCESS_KEY = "test"; | ||
String SECRET_KEY = "test"; | ||
Auth auth = Auth.create(ACCESS_KEY, SECRET_KEY); | ||
|
||
|
||
//实例化一个SmsManager对象 | ||
SmsManager smsManager = new SmsManager(auth); | ||
|
||
|
||
|
||
try { | ||
// Map<String,String> map = new HashMap<String,String>(); | ||
// Response resp = smsManager.sendMessage("templateId", new String[] {"10086"}, map); | ||
// Response resp = smsManager.describeSignature("passed",0,0); | ||
// SignatureInfo sinfo = smsManager.describeSignatureItems("rejected",0,0); | ||
// Response resp = smsManager.createSignature("signature", "app", new String[] {"data:image/gif;base64,xxxxxxxxxx"}); | ||
Response resp = smsManager.describeTemplate("passed",0,0); | ||
// Response resp = smsManager.createTemplate("name","template","notification","test","signatureId"); | ||
// Response resp = smsManager.modifyTemplate("templateId","name","template","test","signatureId"); | ||
// Response resp = smsManager.modifySignature("SignatureId","signature"); | ||
// Response resp = smsManager.deleteSignature("signatureId"); | ||
// Response resp = smsManager.deleteTemplate("templateId"); | ||
System.out.println(resp.bodyString()); | ||
} catch (QiniuException e) { | ||
System.out.println(e); | ||
} | ||
|
||
|
||
} | ||
public static void main(String args[]) { | ||
// 设置需要操作的账号的AK和SK | ||
String ACCESS_KEY = ""; | ||
String SECRET_KEY = ""; | ||
Auth auth = Auth.create(ACCESS_KEY, SECRET_KEY); | ||
|
||
// 实例化一个SmsManager对象 | ||
SmsManager smsManager = new SmsManager(auth); | ||
|
||
try { | ||
Map<String, String> map = new HashMap<String, String>(); | ||
Response resp = smsManager.sendMessage("templateId", new String[] { "10086" }, map); | ||
// Response resp = smsManager.describeSignature("passed", 0, 0); | ||
// Response resp = smsManager.createSignature("signature", "app", | ||
// new String[] { "data:image/gif;base64,xxxxxxxxxx" }); | ||
// Response resp = smsManager.describeTemplate("passed", 0, 0); | ||
// Response resp = smsManager.createTemplate("name", "template", "notification", "test", "signatureId"); | ||
// Response resp = smsManager.modifyTemplate("templateId", "name", "template", "test", "signatureId"); | ||
// Response resp = smsManager.modifySignature("SignatureId", "signature"); | ||
// Response resp = smsManager.deleteSignature("signatureId"); | ||
// Response resp = smsManager.deleteTemplate("templateId"); | ||
System.out.println(resp.bodyString()); | ||
|
||
// SignatureInfo sinfo = smsManager.describeSignatureItems("", 0, 0); | ||
// System.out.println(sinfo.getItems().get(0).getAuditStatus()); | ||
// TemplateInfo tinfo = smsManager.describeTemplateItems("", 0, 0); | ||
// System.out.println(tinfo.getItems().get(0).getAuditStatus()); | ||
|
||
|
||
} catch (QiniuException e) { | ||
System.out.println(e); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package test.com.qiniu; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.util.Arrays; | ||
|
||
public class ResCode { | ||
public static boolean find(int code, int ...codes) { | ||
System.out.println("response code is: " + code + ", expected code is in: " + Arrays.toString(codes)); | ||
for (int i : codes) { | ||
if (code == i) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
public static int[] getPossibleResCode(int ...codes) { | ||
return getPossibleResCode(TestConfig.isTravis(), codes); | ||
} | ||
|
||
public static int[] getPossibleResCode(boolean isTravis, int ...codes) { | ||
if (isTravis) { | ||
int[] n = new int[codes.length + 1]; | ||
System.arraycopy(codes, 0, n, 0, codes.length); | ||
n[codes.length] = -1; // add code -1 for networking failed. | ||
return n; | ||
} | ||
return codes; | ||
} | ||
|
||
@Test | ||
public void testAddCode() { | ||
Assert.assertArrayEquals(new int[]{401, -1}, ResCode.getPossibleResCode(true, 401)); | ||
Assert.assertArrayEquals(new int[]{401}, ResCode.getPossibleResCode(false, 401)); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.