本文整理汇总了Java中com.taobao.api.ApiException类的典型用法代码示例。如果您正苦于以下问题:Java ApiException类的具体用法?Java ApiException怎么用?Java ApiException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ApiException类属于com.taobao.api包,在下文中一共展示了ApiException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: SendPhoneToCustom
import com.taobao.api.ApiException; //导入依赖的package包/类
@RequestMapping(path = "/phone/send", method = RequestMethod.POST)
public PhoneVo SendPhoneToCustom(@RequestBody PhoneVo vo) throws ApiException {
System.err.println(vo.getPhone());
vo.setCode(RandomStringUtils.randomNumeric(6));
// 24619654
String url = "https://eco.taobao.com/router/rest";
String appkey = "";
String secret = "a68a283919212762db0f58132e1c76bd";
TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
req.setExtend("123456");
req.setSmsType("normal");
req.setSmsFreeSignName("数盟");
req.setSmsParamString("{\"code\":\"" + vo.getCode() + "\"}");
req.setRecNum(vo.getPhone());
req.setSmsTemplateCode("SMS_94715134");
AlibabaAliqinFcSmsNumSendResponse rsp = client.execute(req);
System.out.println(rsp.getBody());
return vo;
}
开发者ID:514840279,项目名称:danyuan-application,代码行数:23,代码来源:SimapleMailRegist.java
示例2: sendText
import com.taobao.api.ApiException; //导入依赖的package包/类
public static String sendText(String content) {
try {
Map<String, String> msgcontent = new HashMap<>();
msgcontent.put("content", content);
DingTalkClient client = new DefaultDingTalkClient("https://eco.taobao.com/router/rest");
CorpMessageCorpconversationAsyncsendRequest req = new CorpMessageCorpconversationAsyncsendRequest();
req.setMsgtype("text");
req.setAgentId(Utils.parseLong(agentid, null));
req.setToAllUser(true);
req.setMsgcontent(JSON.toJSONString(msgcontent));
CorpMessageCorpconversationAsyncsendResponse rsp = client.execute(req, getToken());
System.out.println(rsp.getBody());
} catch (ApiException e) {
e.printStackTrace();
}
return null;
}
开发者ID:JiaXiaohei,项目名称:elasticjob-stock-push,代码行数:20,代码来源:DingtalkUtil.java
示例3: toResponse
import com.taobao.api.ApiException; //导入依赖的package包/类
@Override
public <T extends TaobaoResponse> T toResponse(String rsp, Class<T> clazz) throws ApiException {
JSONReader reader = new JSONValidatingReader(new ExceptionErrorListener());
Object rootObj = reader.read(rsp);
if (rootObj instanceof Map<?, ?>) {
Map<?, ?> rootJson = (Map<?, ?>) rootObj;
Collection<?> values = rootJson.values();
for (Object rspObj : values) {
if (rspObj instanceof Map<?, ?>) {
Map<?, ?> rspJson = (Map<?, ?>) rspObj;
return fromJson(rspJson, clazz);
}
}
}
return null;
}
开发者ID:kuiwang,项目名称:my-dev,代码行数:17,代码来源:JsonConverter.java
示例4: parse
import com.taobao.api.ApiException; //导入依赖的package包/类
@Override
public TdcResponse parse(String rsp) throws ApiException {
JXTdcResponse jxRsp = new JXTdcResponse();
Map<String, Object> resultMap = new HashMap<String, Object>();
XmlReader xmlreader = new XmlReader();
try {
StringReader sr = new StringReader(rsp);
InputSource is = new InputSource(sr);
Document document = XmlUtils.getDocument(is, null);
Element root = document.getDocumentElement();
Map<String, Object> parserMap = xmlreader.dom2Map(root);
if (root.getNodeName().equals(Constants.ERROR_RESPONSE)) {
jxRsp.setErrorCode((String) parserMap.get(Constants.ERROR_CODE));
jxRsp.setMsg((String) parserMap.get(Constants.ERROR_MSG));
jxRsp.setSubCode((String) parserMap.get(Constants.ERROR_SUB_CODE));
jxRsp.setSubMsg((String) parserMap.get(Constants.ERROR_SUB_MSG));
} else {
resultMap.put(root.getNodeName(), parserMap);
}
} catch (Exception e) {
throw new ApiException(e);
}
jxRsp.setResultMap(resultMap);
jxRsp.setBody(rsp);
return jxRsp;
}
开发者ID:kuiwang,项目名称:my-dev,代码行数:27,代码来源:TdcXmlParser.java
示例5: parse
import com.taobao.api.ApiException; //导入依赖的package包/类
@Override
public TdcResponse parse(String rsp) throws ApiException {
TdcResponse rsponse = new TdcResponse();
JSONReader reader = new JSONValidatingReader(new ExceptionErrorListener());
Object rootObj = reader.read(rsp);
if (rootObj instanceof Map<?, ?>) {
Map<?, ?> rootJson = (Map<?, ?>) rootObj;
if (rootJson.containsKey(Constants.ERROR_RESPONSE)) {
Map<?, ?> result = (Map<?, ?>) rootJson.get(Constants.ERROR_RESPONSE);
rsponse.setErrorCode((String) result.get(Constants.ERROR_CODE));
rsponse.setMsg((String) result.get(Constants.ERROR_MSG));
rsponse.setSubCode((String) result.get(Constants.ERROR_SUB_CODE));
rsponse.setSubMsg((String) result.get(Constants.ERROR_SUB_MSG));
}
}
rsponse.setBody(rsp);
return rsponse;
}
开发者ID:kuiwang,项目名称:my-dev,代码行数:21,代码来源:TdcMbpBackParser.java
示例6: parse
import com.taobao.api.ApiException; //导入依赖的package包/类
@Override
public TdcResponse parse(String rsp) throws ApiException {
JXTdcResponse jxRsp = new JXTdcResponse();
JSONReader reader = new JSONValidatingReader(new ExceptionErrorListener());
Object rootObj = reader.read(rsp);
if (rootObj instanceof Map<?, ?>) {
Map<?, ?> rootJson = (Map<?, ?>) rootObj;
if (rootJson.containsKey(Constants.ERROR_RESPONSE)) {
Map<?, ?> result = (Map<?, ?>) rootJson.get(Constants.ERROR_RESPONSE);
jxRsp.setErrorCode((String) result.get(Constants.ERROR_CODE));
jxRsp.setMsg((String) result.get(Constants.ERROR_MSG));
jxRsp.setSubCode((String) result.get(Constants.ERROR_SUB_CODE));
jxRsp.setSubMsg((String) result.get(Constants.ERROR_SUB_MSG));
} else {
jxRsp.setResultMap(rootJson);
}
}
jxRsp.setBody(rsp);
return jxRsp;
}
开发者ID:kuiwang,项目名称:my-dev,代码行数:23,代码来源:TdcJsonParser.java
示例7: childNodeToString
import com.taobao.api.ApiException; //导入依赖的package包/类
/**
* Converts the Node/Element instance to XML payload.
*
* @param node the node/element instance to convert
* @return the XML payload representing the node/element
* @throws ApiException problem converting XML to string
*/
public static String childNodeToString(Node node) throws ApiException {
String payload = null;
try {
Transformer tf = TransformerFactory.newInstance().newTransformer();
Properties props = tf.getOutputProperties();
props.setProperty(OutputKeys.OMIT_XML_DECLARATION, LOGIC_YES);
props.setProperty(OutputKeys.ENCODING, DEFAULT_CHARSET);
tf.setOutputProperties(props);
StringWriter writer = new StringWriter();
tf.transform(new DOMSource(node), new StreamResult(writer));
payload = escapeXml(writer.toString());
} catch (TransformerException e) {
throw new ApiException("XML_TRANSFORM_ERROR", e);
}
return payload;
}
开发者ID:kuiwang,项目名称:my-dev,代码行数:28,代码来源:XmlUtils.java
示例8: nodeToString
import com.taobao.api.ApiException; //导入依赖的package包/类
/**
* Converts the Node/Document/Element instance to XML payload.
*
* @param node the node/document/element instance to convert
* @return the XML payload representing the node/document/element
* @throws ApiException problem converting XML to string
*/
public static String nodeToString(Node node) throws ApiException {
String payload = null;
try {
Transformer tf = TransformerFactory.newInstance().newTransformer();
Properties props = tf.getOutputProperties();
props.setProperty(OutputKeys.ENCODING, DEFAULT_CHARSET);
props.setProperty(OutputKeys.INDENT, LOGIC_YES);
tf.setOutputProperties(props);
StringWriter writer = new StringWriter();
tf.transform(new DOMSource(node), new StreamResult(writer));
payload = escapeXml(writer.toString());
} catch (TransformerException e) {
throw new ApiException("XML_TRANSFORM_ERROR", e);
}
return payload;
}
开发者ID:kuiwang,项目名称:my-dev,代码行数:28,代码来源:XmlUtils.java
示例9: saveToXml
import com.taobao.api.ApiException; //导入依赖的package包/类
/**
* Saves the node/document/element as XML file.
*
* @param doc the XML node/document/element to save
* @param file the XML file to save
* @param charset the string encoding charset
* @throws ApiException problem persisting XML file
*/
public static void saveToXml(Node doc, File file, String charset) throws ApiException {
Writer writer = null;
try {
Transformer tf = TransformerFactory.newInstance().newTransformer();
Properties props = tf.getOutputProperties();
props.setProperty(OutputKeys.METHOD, XMLConstants.XML_NS_PREFIX);
props.setProperty(OutputKeys.INDENT, LOGIC_YES);
tf.setOutputProperties(props);
DOMSource dom = new DOMSource(doc);
writer = new OutputStreamWriter(getOutputStream(file), charset);
Result result = new StreamResult(writer);
tf.transform(dom, result);
} catch (Exception e) {
throw new ApiException("XML_WRITE_FILE_ERROR", e);
} finally {
closeStream(writer);
}
}
开发者ID:kuiwang,项目名称:my-dev,代码行数:30,代码来源:XmlUtils.java
示例10: xmlToHtml
import com.taobao.api.ApiException; //导入依赖的package包/类
/**
* Transforms the XML content to XHTML/HTML format string with the XSL.
*
* @param payload the XML payload to convert
* @param xsltFile the XML stylesheet file
* @return the transformed XHTML/HTML format string
* @throws ApiException problem converting XML to HTML
*/
public static String xmlToHtml(String payload, File xsltFile) throws ApiException {
String result = null;
try {
Source template = new StreamSource(xsltFile);
Transformer transformer = TransformerFactory.newInstance().newTransformer(template);
Properties props = transformer.getOutputProperties();
props.setProperty(OutputKeys.OMIT_XML_DECLARATION, LOGIC_YES);
transformer.setOutputProperties(props);
StreamSource source = new StreamSource(new StringReader(payload));
StreamResult sr = new StreamResult(new StringWriter());
transformer.transform(source, sr);
result = sr.getWriter().toString();
} catch (TransformerException e) {
throw new ApiException("XML_TRANSFORM_ERROR", e);
}
return result;
}
开发者ID:kuiwang,项目名称:my-dev,代码行数:31,代码来源:XmlUtils.java
示例11: addProtocalMustParams
import com.taobao.api.ApiException; //导入依赖的package包/类
private <T extends AliyunResponse> void addProtocalMustParams(AliyunRequest<T> request,
TaobaoHashMap protocalMustParams) throws Exception {
String[] strArray = request.getApiMethodName().split("\\.");
if (strArray.length < 5) {
throw new ApiException("Wrong api name.");
}
String action = strArray[3];
protocalMustParams.put(AliyunConstants.ACTION, action);
String version = strArray[4];
protocalMustParams.put(AliyunConstants.VERSION, version);
protocalMustParams.put(AliyunConstants.ACCESS_KEY_ID, accessKeyId);
protocalMustParams.put(AliyunConstants.FORMAT, format);
Long timestamp = request.getTimestamp();// 允许用户设置时间戳
if (timestamp == null) {
timestamp = System.currentTimeMillis();
}
protocalMustParams.put(AliyunConstants.TIME_STAMP, formatIso8601Date(new Date(timestamp)));
protocalMustParams.put(AliyunConstants.SIGNATURE_METHOD, signatureMethod);
protocalMustParams.put(AliyunConstants.SIGNATURE_VERSION, signatureVersion);
protocalMustParams.put(AliyunConstants.SIGNATURE_NONCE, UUID.randomUUID().toString()); // 可以使用UUID作为SignatureNonce
}
开发者ID:kuiwang,项目名称:my-dev,代码行数:25,代码来源:DefaultAliyunClient.java
示例12: getSellerInfo
import com.taobao.api.ApiException; //导入依赖的package包/类
public void getSellerInfo() {
// 实例化TopClient类
TaobaoClient client = new DefaultTaobaoClient(serverUrl, appkey, appSecret);
// 实例化具体API对应的Request类
UserSellerGetRequest req = new UserSellerGetRequest();
req.setFields("nick, user_id, type");
// req.setNick("sandbox_c_1");
// 执行API请求并打印结果
UserSellerGetResponse response;
try {
response = client.execute(req, sessionkey);
System.out.println("result: " + response.getBody());
} catch (ApiException e) {
e.printStackTrace();
}
}
开发者ID:colddew,项目名称:mix-web,代码行数:21,代码来源:TopAPI.java
示例13: sentValidCodeSms
import com.taobao.api.ApiException; //导入依赖的package包/类
/**
* 发送验证码
* @param mobileNum 手机号
* @param validCode 验证码内容
* @param signName 短信签名
* @param templateNum 模板号
* @param opeateName 操作名称(日志用)
* @return 发送是否成功
*/
private boolean sentValidCodeSms(String mobileNum, String validCode,String signName,String templateNum,String opeateName){
AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
req.setSmsType("normal");
req.setSmsFreeSignName(signName);
req.setSmsParamString("{\"code\":\"" + validCode + "\",\"product\":\" "+SMS_PRODUCT_NAME+" \"}");
req.setRecNum(mobileNum);
req.setSmsTemplateCode(templateNum);
AlibabaAliqinFcSmsNumSendResponse rsp ;
try {
rsp = getSmsClient().execute(req);
if (rsp==null){
log.error("验证码-"+opeateName+"-失败:返回结果为null,mobile:{} validCode{}",mobileNum,validCode);
return false;
}else{
if(!rsp.isSuccess()){
log.error("验证码-"+opeateName+"-失败:返回结果失败:,mobile:{} code:{} response:{}",mobileNum,validCode, ReflectionToStringBuilder.toString(rsp, ToStringStyle.SIMPLE_STYLE));
return false;
}
}
} catch (ApiException e) {
log.error("验证码-"+opeateName+"-失败:短信发送异常,mobile:"+mobileNum+" code:"+validCode, e);
}
log.info("验证码-"+opeateName+":发送成功,mobile:{} validCode:{}",mobileNum,validCode);
return true;
}
开发者ID:yangshuai0711,项目名称:dingding-app-server,代码行数:36,代码来源:SmsServiceWrapImpl.java
示例14: parse
import com.taobao.api.ApiException; //导入依赖的package包/类
@Override
public T parse(String rsp) throws ApiException {
Converter converter;
if (this.simplify) {
converter = new SimplifyJsonConverter();
} else {
converter = new JsonConverter();
}
return converter.toResponse(rsp, clazz);
}
开发者ID:kuiwang,项目名称:my-dev,代码行数:11,代码来源:ObjectJsonParser.java
示例15: toResponse
import com.taobao.api.ApiException; //导入依赖的package包/类
@Override
public <T extends TaobaoResponse> T toResponse(String rsp, Class<T> clazz) throws ApiException {
JSONReader reader = new JSONValidatingReader(new ExceptionErrorListener());
Object rootObj = reader.read(rsp);
if (rootObj instanceof Map<?, ?>) {
Map<?, ?> rootJson = (Map<?, ?>) rootObj;
Object errorJson = rootJson.get(Constants.ERROR_RESPONSE);
if (errorJson instanceof Map<?, ?>) {
return fromJson((Map<?, ?>) errorJson, clazz);
} else {
return fromJson(rootJson, clazz);
}
}
return null;
}
开发者ID:kuiwang,项目名称:my-dev,代码行数:16,代码来源:SimplifyJsonConverter.java
示例16: parse
import com.taobao.api.ApiException; //导入依赖的package包/类
@Override
public CsvTdcResponse parse(String rsp) throws ApiException {
CsvTdcResponse csvRsp = new CsvTdcResponse();
CsvReader cr = CsvReader.parse(rsp);
CsvMetaData metaData = new CsvMetaData();
List<String[]> csvResult = new ArrayList<String[]>();
try {
boolean hasReadHeader = false;
while (cr.readRecord()) {
if (!hasReadHeader) {
String[] headers = cr.getValues();
for (String header : headers) {
int index = header.indexOf(".");
if (index == -1) {
if (header.equals(Constants.ERROR_RESPONSE)) {
errorRecord(cr, csvRsp, rsp, headers);
return csvRsp;
}
metaData.addMetaData(null, null, header);
} else {
metaData.addMetaData(header.substring(0, index),
header.substring(index + 1, header.length()), header);
}
}
hasReadHeader = true;
} else {
String[] values = cr.getValues();
csvResult.add(values);
}
}
} catch (Exception e) {
throw new ApiException(e);
}
csvRsp.setMetaData(metaData);
csvRsp.setCsvResult(csvResult);
csvRsp.setBody(rsp);
return csvRsp;
}
开发者ID:kuiwang,项目名称:my-dev,代码行数:40,代码来源:TdcCsvParser.java
示例17: _execute
import com.taobao.api.ApiException; //导入依赖的package包/类
private TdcResponse _execute(TdcRequest request, String session, TdcParser parser,
String format) throws ApiException {
TdcResponse tdcRsp = null;
String rsp = doPost(request, session, format);
if (needEnableParser) {
tdcRsp = parser.parse(rsp);
} else {
tdcRsp = new TdcResponse();
tdcRsp.setBody(rsp);
}
return tdcRsp;
}
开发者ID:kuiwang,项目名称:my-dev,代码行数:13,代码来源:DefaultTdcClient.java
示例18: csvExecute
import com.taobao.api.ApiException; //导入依赖的package包/类
@Override
public CsvTdcResponse csvExecute(TdcRequest request, String session) throws ApiException {
TdcParser parser = null;
if (needEnableParser) {
parser = new TdcCsvParser();
}
return (CsvTdcResponse) _execute(request, session, parser, "csv");
}
开发者ID:kuiwang,项目名称:my-dev,代码行数:9,代码来源:DefaultTdcClient.java
示例19: jsonExecute
import com.taobao.api.ApiException; //导入依赖的package包/类
@Override
public JXTdcResponse jsonExecute(TdcRequest request, String session) throws ApiException {
TdcParser parser = null;
if (needEnableParser) {
parser = new TdcJsonParser();
}
return (JXTdcResponse) _execute(request, session, parser, Constants.FORMAT_JSON);
}
开发者ID:kuiwang,项目名称:my-dev,代码行数:9,代码来源:DefaultTdcClient.java
示例20: xmlExecute
import com.taobao.api.ApiException; //导入依赖的package包/类
@Override
public JXTdcResponse xmlExecute(TdcRequest request, String session) throws ApiException {
TdcParser parser = null;
if (needEnableParser) {
parser = new TdcXmlParser();
}
return (JXTdcResponse) _execute(request, session, parser, Constants.FORMAT_XML);
}
开发者ID:kuiwang,项目名称:my-dev,代码行数:9,代码来源:DefaultTdcClient.java
注:本文中的com.taobao.api.ApiException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论