In general, I registered the application in stackapps and got the Key. Then I found an example and tried to run it, but I catch a mistake, someone can tell what the problem is? or show usable tutorial on using StackExchangeApi
Here is the code:
public class Main { public static void main(String[] args) { StackExchangeApiClientFactory factory = StackExchangeApiClientFactory.newInstance("dybйjLCjoйй0BA*g*rMYyDA(("); StackExchangeApiClient client = factory.createStackExchangeApiClient(); List<Question> questions = client.getQuestions(Question.SortOrder.HOT, new Paging(1, 20), new TimePeriod(new Date(), new Date()), EnumSet.of(FilterOption.INCLUDE_BODY, FilterOption.INCLUDE_COMMENTS)); for (Question q : questions) { System.out.println(q.getBody()); } } }
and standard error:
Exception in thread "main" java.lang.NullPointerException at com.google.code.stackexchange.client.impl.StackExchangeApiGateway.callApiMethod(StackExchangeApiGateway.java:269) at com.google.code.stackexchange.client.impl.StackExchangeApiGateway.callApiMethod(StackExchangeApiGateway.java:233) at com.google.code.stackexchange.client.impl.BaseStackExchangeApiClient.getQuestions(BaseStackExchangeApiClient.java:288) at Main.main(Main.java:20) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
after changing the old one to the new one it gives out:
Exception in thread "main" java.lang.ExceptionInInitializerError at com.google.code.stackexchange.client.query.impl.BaseStackOverflowApiQuery.<clinit>(BaseStackOverflowApiQuery.java:84) at com.google.code.stackexchange.client.query.StackExchangeApiQueryFactory.newQuestionApiQuery(StackExchangeApiQueryFactory.java:179) at Main.callStackExchange(Main.java:90) [INFO] StackExchange API Java SDK ......................... SUCCESS [ 1.747 s] [INFO] stackexchange-java-schema .......................... SUCCESS [ 5.533 s] [INFO] stackexchange-java-core ............................ FAILURE [01:30 min] [INFO] stackoverflow-java-sdk-release ..................... SKIPPED [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 01:37 min [INFO] Finished at: 2016-08-03T17:39:21+03:00 [INFO] Final Memory: 29M/347M