xinge-api-java
xinge-api-java copied to clipboard
信鸽ServerSDK-Java版本
没法发自定义消息啊 custom 类型是string? 不应该是json吗
如下图,在调用推送代码的时候频繁的出现空指针异常,请麻烦看一下,感谢。 
Exception in thread "main" org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1] at org.json.JSONTokener.syntaxError(JSONTokener.java:451) at org.json.JSONObject.(JSONObject.java:195) at org.json.JSONObject.(JSONObject.java:319) at com.tencent.xinge.XingeApp.callRestful(XingeApp.java:145) at com.tencent.xinge.XingeApp.pushApp(XingeApp.java:62) at com.loovee.newsale.business.service.impl.PushServiceImpl.main(PushServiceImpl.java:58)...
https://github.com/xingePush/xinge-api-java/blob/master/src/main/java/com/tencent/xinge/XingeApp.java#L42 ``` String hostname = "localhost"/*127.0.0.1*/; int port = 1080; Proxy proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(hostname, port)); OkHttpClient.Builder builder = new OkHttpClient.Builder().proxy(proxy); OkHttpClient client = builder.build(); ```
1 代码中命名不规范的问题 2 部分对象json 序列化格式 与官网 请求格式不一致 3 部分代码测试用例不严谨
1、com.tencent.xinge.push.app.PushTagAndroidTest#testPushTagAndroid 这个方法看着是个安卓标签推送。 但是! 代码里面写的audience_type设置的缺失,导致使用了默认值。AudienceType.all 不光不是tag推送,而且是全量推送。 刚刚,我测试了一下,结果某环境全量推了,脸都绿了!!! 希望作者,修改。防止他人产生同样问题。 另外,就是默认值的问题。这种关键性的值,我觉得请不要设置默认值。严格要求上层输入。不然真的容易出问题。 2、 com.tencent.xinge.device.tag.DeviceTagRequest#tag_token_list 缺失 @JsonFormat(shape = JsonFormat.Shape.ARRAY) 因为官方文档要求的是, 对list的要求是 [["tag1","token1"],["tag2","token2"]] 而不是 [{"tag":"tag1","token":"token1"}] 建议检查所有的List参数。全部加上@JsonFormat(shape = JsonFormat.Shape.ARRAY)
_Originally posted by @xiaoshyang in https://github.com/xingePush/xinge-api-java/issues/23#issuecomment-433033531_
测试代码不能通过。 请求中jackson序列化的时候。 1、枚举类com.tencent.xinge.bean.Platform 中, @JsonValue注解 在getType() 上,看官方文档应该在getName()上。 2、类com.tencent.xinge.device.tag.DeviceTagRequest 中,@JsonProperty注解 value = "audience_type",官方文档应该还是operator_type。 修改之后。测试通过。
在XingeApp类:掉了一句https.setHostnameVerifier(new TrustAnyHostnameVerifier());吧,不然ssl证书验证过不去。 private JSONObject callRestful(String apiAddress, String jsonRequestString) { URL url; HttpURLConnection http = null; InputStreamReader isr = null; BufferedReader br = null; String ret = ""; String temp; JSONObject...