@Test public void testGetToken() { QNUploader uploader = new QNUploader(); try { AuthInfo auth = uploader.getToken("157250921_1", "", "", "", "qrcode.png"); System.out.println(auth); assertNotNull(auth); assertNotNull(auth.token); assertEquals("http: assertEquals(1, auth.days); assertEquals(8 << 20, auth.limit); auth = uploader.getToken("157250921_1", "ak", "sk", "", "qrcode.png"); System.out.println(auth); assertNotNull(auth); assertEquals(0, auth.days); assertEquals(0 << 20, auth.limit); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
public AuthInfo getToken(String qq, String ak, String sk, String bucket, String key) throws Exception { RequestBody body = new FormBody.Builder().add("key", key) .add("bucket", bucket).add("qq", qq).build(); Request.Builder builder = new Request.Builder().url(API_GET_TOKEN) .addHeader("accessKey", ak).addHeader("secretKey", sk) .post(body); Request request = builder.build(); Call call = this.client.newCall(request); Response response = call.execute(); AuthResponse info = null; String json = response.body().string(); System.out.println(json); if (response.code() == 200) { info = new Gson().fromJson(json, AuthResponse.class); } if (info == null) { throw new RuntimeException(response.message()); } if (info.code != 0 || info.data == null) { throw new RuntimeException(info.msg); } return info.data; }
QNUploader { public AuthInfo getToken(String qq, String ak, String sk, String bucket, String key) throws Exception { RequestBody body = new FormBody.Builder().add("key", key) .add("bucket", bucket).add("qq", qq).build(); Request.Builder builder = new Request.Builder().url(API_GET_TOKEN) .addHeader("accessKey", ak).addHeader("secretKey", sk) .post(body); Request request = builder.build(); Call call = this.client.newCall(request); Response response = call.execute(); AuthResponse info = null; String json = response.body().string(); System.out.println(json); if (response.code() == 200) { info = new Gson().fromJson(json, AuthResponse.class); } if (info == null) { throw new RuntimeException(response.message()); } if (info.code != 0 || info.data == null) { throw new RuntimeException(info.msg); } return info.data; } }
QNUploader { public AuthInfo getToken(String qq, String ak, String sk, String bucket, String key) throws Exception { RequestBody body = new FormBody.Builder().add("key", key) .add("bucket", bucket).add("qq", qq).build(); Request.Builder builder = new Request.Builder().url(API_GET_TOKEN) .addHeader("accessKey", ak).addHeader("secretKey", sk) .post(body); Request request = builder.build(); Call call = this.client.newCall(request); Response response = call.execute(); AuthResponse info = null; String json = response.body().string(); System.out.println(json); if (response.code() == 200) { info = new Gson().fromJson(json, AuthResponse.class); } if (info == null) { throw new RuntimeException(response.message()); } if (info.code != 0 || info.data == null) { throw new RuntimeException(info.msg); } return info.data; } QNUploader(); }
QNUploader { public AuthInfo getToken(String qq, String ak, String sk, String bucket, String key) throws Exception { RequestBody body = new FormBody.Builder().add("key", key) .add("bucket", bucket).add("qq", qq).build(); Request.Builder builder = new Request.Builder().url(API_GET_TOKEN) .addHeader("accessKey", ak).addHeader("secretKey", sk) .post(body); Request request = builder.build(); Call call = this.client.newCall(request); Response response = call.execute(); AuthResponse info = null; String json = response.body().string(); System.out.println(json); if (response.code() == 200) { info = new Gson().fromJson(json, AuthResponse.class); } if (info == null) { throw new RuntimeException(response.message()); } if (info.code != 0 || info.data == null) { throw new RuntimeException(info.msg); } return info.data; } QNUploader(); AuthInfo getToken(String qq, String ak, String sk, String bucket,
            String key); UploadInfo upload(String qq, File file, String ak, String sk,
            String bucket, Zone zone); }
QNUploader { public AuthInfo getToken(String qq, String ak, String sk, String bucket, String key) throws Exception { RequestBody body = new FormBody.Builder().add("key", key) .add("bucket", bucket).add("qq", qq).build(); Request.Builder builder = new Request.Builder().url(API_GET_TOKEN) .addHeader("accessKey", ak).addHeader("secretKey", sk) .post(body); Request request = builder.build(); Call call = this.client.newCall(request); Response response = call.execute(); AuthResponse info = null; String json = response.body().string(); System.out.println(json); if (response.code() == 200) { info = new Gson().fromJson(json, AuthResponse.class); } if (info == null) { throw new RuntimeException(response.message()); } if (info.code != 0 || info.data == null) { throw new RuntimeException(info.msg); } return info.data; } QNUploader(); AuthInfo getToken(String qq, String ak, String sk, String bucket,
            String key); UploadInfo upload(String qq, File file, String ak, String sk,
            String bucket, Zone zone); static String API_URL; static String API_GET_TOKEN; static String API_CALLBACK; }