GithubHelp home page GithubHelp logo

yunpian-java-sdk's Issues

如何覆盖配置文件中的值

服务器在美国,调用国内云片服务器会有很大延迟。使用jar包或maven可以如下覆盖配置项:

import java.util.Properties;
// ..........

Properties prop = new Properties();
prop.setProperty("yp.user.host","https://us.yunpian.com");
prop.setProperty("yp.sign.host","https://us.yunpian.com");
prop.setProperty("yp.tpl.host","https://us.yunpian.com");
prop.setProperty("yp.sms.host","https://us.yunpian.com");
prop.setProperty("yp.short_url.host","https://us.yunpian.com");

//初始化clnt,使用单例方式
YunpianClient clnt = new YunpianClient("5dd0287******apikey*****900441", prop).init();

为什么调用new SmsApi().single_send(params)会失败

Map<String, String> params = new HashMap<String, String>();
params.put("apikey", "xxxxxxxxxxxxxxxxxxx");
params.put("text", text);
params.put("mobile", mobile);
Result result = new SmsApi().single_send(params);

为什么会失败,失败的原因是YunpianApi 的uri()方法报空指针异常?还需要加什么参数呢?

根据ID获取模版报异常

根据接口文档,传了模版ID的时候,应该返回的是单个对象,不传时,返回的是一个数组。根据java-sdk里面的接口定义,两种情况下返回的都是数组。现在在传了模版ID之后会报json异常。

ResultDO{data=null, success=false, e=com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $}
public ResultDO<List<TemplateInfo>> get(final String tplId) {
        return send(Config.URI_GET_TPL_SMS, new HashMap<String, String>() {{
            put(YunpianConstants.TPL_ID, tplId);
        }}, new TypeToken<List<TemplateInfo>>() {
        }.getType());
    }

    public ResultDO<List<TemplateInfo>> get() {
        return get("");
    }

关于指定模板单发和指定模板群发

关于指定模板单发和指定模板群发

这两个都被弃用了,没有指定替代方法或者是相关解释,请问,该如何使用指定模板发送短信相关功能?

指定模板单发

image

指定模板群发

image

关于直接发短信验证码变量未直接替换问题

使用接口:指定模板单发
使用模板样式:【#company#】验证码#code#,您正在进行#option#,#eftime#有效。若非本人操作,请勿泄露。
请求参数:apikey=XXXXXXXXX&tpl_id=25525&mobile=139***********&tpl_value=#code#=1342&#eftime#=10%E5%88%86%E9%92%9F&#company#=%E4%BC%97%E5%BA%B7%E4%BA%91&#option#=%E6%BF%80%E6%B4%BB%E8%B4%A6%E6%88%B7
如果发送错误:解析出来的结果如下
image
发送成功用户收到的样式:
只替换掉了company,code两个变量,option和eftime没有替换成功。结果为:
【签名】验证码1523,您正在进行#option#,#eftime#有效。若非本人操作,请勿泄露。
上面为问题反馈,虽然可以通过单发接口发送想要的样式。遇到了还是给你们说下。
另外不得不吐槽下你们的售后,态度太牛逼了。
给它各种说明情况,叫给查一下问题,然后说自己弄的不对。最气的是最后来一句自己百度怎么替换变量。

短信内容有英文单词时,发送不成功,见图

用的是readme里面的方法发送:

//初始化clnt,使用单例方式
YunpianClient clnt = new YunpianClient("apikey").init();

//发送短信API
Map<String, String> param = clnt.newParam(2);
param.put(YunpianClient.MOBILE, "18616020***");
param.put(YunpianClient.TEXT, "【云片网】您的验证码是1234");
Result<SmsSingleSend> r = clnt.sms().single_send(param);
//获取返回结果,返回码:r.getCode(),返回码描述:r.getMsg(),API结果:r.getData(),其他说明:r.getDetail(),调用异常:r.getThrowable()

//账户:clnt.user().* 签名:clnt.sign().* 模版:clnt.tpl().* 短信:clnt.sms().* 语音:clnt.voice().* 流量:clnt.flow().* 隐私通话:clnt.call().*

//释放clnt
clnt.close() 

只是内容中包含英文字母,就发送失败

image

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.