Skip to content

Latest commit

 

History

History
54 lines (48 loc) · 1.77 KB

README.md

File metadata and controls

54 lines (48 loc) · 1.77 KB

ZoomEye-API

ZoomEye Android API

Gradle

Download

compile 'org.droiders:zoomeye-api:0.0.4'

Usage

  • Create ZoomEyeApiService object
Retrofit retrofit = new Retrofit.Builder() //
      .client(client) //
      .baseUrl("http://api.zoomeye.org") //
      .addConverterFactory(GsonConverterFactory.create(gson)) //
      .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) //
      .build();
ZoomEyeApiService api = retrofit.create(ZoomEyeApiService.class);
  • Request and error handle
ErrorBodyHandler errorHandler = new ErrorBodyHandler(retrofit);

api.login(new LoginRequest(username, password))
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe(tokenResponse -> {
      if (tokenResponse.isSuccessful()) {
        String accessToken = tokenResponse.body().toString();
        Log.d("ZoomEye", "accessToken = " + accessToken);
        ...
      } else {
        ErrorBody errorBody = errorHandler.parseError(tokenResponse.errorBody());
        Log.d("ZoomEye", errorBody.getMessage());
        ...
      }
    });

License

Copyright 2016 Huang Donglu

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.