This is a Java SDK for zhihuDaily
Firstly, get client by invoking ZhihuDailyClient.create()
ZhihuDaily zhihuDaily = ZhihuDailyClient.create();
You can use the client to call API with synchronous
and asynchronous
way.
To do a synchronous call, you need to invoke execute()
.
DailyNews dailyNews = zhihuDaily.getLatestNews().execute();
dailyNews.getStories().forEach(System.out::println);
To do a asynchronous call, you need to invoke enqueue()
zhihuDaily.getLatestNews().enqueue(new ServiceCallback<DailyNews>() {
@Override
public void onResponse(DailyNews object) {
object.getStories().forEach(System.out::println);
}
@Override
public void onFailure(HttpException exception) {
System.out.println(exception.getMessage());
}
});
You can find more examples from here: examples
- Java8+
Maven:
<dependency>
<groupId>com.github.ndrlslz</groupId>
<artifactId>zhihuDaily-java-client</artifactId>
<version>0.1.2</version>
</dependency
Gradle:
compile 'com.github.ndrlslz:zhihuDaily-java-client:0.1.2'