Giter Club home page Giter Club logo

botometer-java's People

Contributors

dependabot[bot] avatar fxjordan avatar themrmilchmann avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

botometer-java's Issues

API error (statusCode: 404): null - API doesn't exists

I'm getting "API doesn't exists" in your code DefaultBotometerClient when you make the call to:

`
RequestBody body = RequestBody.create(JSON_MEDIA_TYPE, accountDataJson);
Request request = new Request.Builder().url(BOTOMETER_CHECK_ACCOUNT_URL).header("X-RapidAPI-Key", this.apiKey)
.post(body).build();

    try (Response response = this.httpClient.newCall(request).execute()) {
        if (response.isSuccessful()) {
            return readClassifcationResult(response.body());
        } else {
            throw createApiErrorException(response);
        }
    }

`

Here is my code
`
BotometerConfiguration config = new BotometerConfigurationBuilder()
.botometerApiKey("...")
.twitterConsumerKey("...")
.twitterConsumerSecret("...")
.twitterAccessToken("...")
.twitterAccessTokenSecret("...").build();
Botometer botometer = new BotometerFactory(config).create();

    AccountAnalysisResult result = botometer.analyzeAccount("realDonaldTrump");
    log.debug("result: {}",result);

`

I'm getting the following exception:

at de.fjobilabs.botometer.AccountAnalyzingBotometer.analyzeAccountData(AccountAnalyzingBotometer.java:85) at de.fjobilabs.botometer.AccountAnalyzingBotometer.analyzeAccount(AccountAnalyzingBotometer.java:72) at com.xuan.bot.service.BotMeterServiceTest.testAnalyzeTwitterAccount(BotMeterServiceTest.java:24) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:686) at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131) at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84) at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115) at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:212) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:208) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:137) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:71) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at java.base/java.util.ArrayList.forEach(ArrayList.java:1510) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at java.base/java.util.ArrayList.forEach(ArrayList.java:1510) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:248) at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$5(DefaultLauncher.java:211) at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:226) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:199) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:132) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58) Caused by: de.fjobilabs.botometer.api.BotometerApiException: API error (statusCode: 404): null - API doesn't exists at de.fjobilabs.botometer.api.BotometerApiException.create(BotometerApiException.java:75) at de.fjobilabs.botometer.client.DefaultBotometerClient.createApiErrorException(DefaultBotometerClient.java:87) at de.fjobilabs.botometer.client.DefaultBotometerClient.checkAccount(DefaultBotometerClient.java:70) at de.fjobilabs.botometer.client.AbstractBotometerClient.checkAccountDTO(AbstractBotometerClient.java:79) at de.fjobilabs.botometer.client.AbstractBotometerClient.checkAccount(AbstractBotometerClient.java:74) at de.fjobilabs.botometer.AccountAnalyzingBotometer.analyzeAccountData(AccountAnalyzingBotometer.java:83) ... 65 more

NullPointerException on analyzeAccount(..)

Hi,
i'm using your libraries but i get an error during execution. In particular it gives NullPointerException in:

Exception in thread "main" java.lang.NullPointerException
at java.util.Locale.(Locale.java:648)
at java.util.Locale.(Locale.java:701)
at de.fjobilabs.botometer.twitterclient.twitter4j.Twitter4JUser.getLang(Twitter4JUser.java:137)
at de.fjobilabs.twitter.dto.UserDTO.(UserDTO.java:115)
at de.fjobilabs.twitter.dto.TweetDTO.(TweetDTO.java:115)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at de.fjobilabs.botometer.client.AbstractBotometerClient.checkAccount(AbstractBotometerClient.java:72)
at de.fjobilabs.botometer.AccountAnalyzingBotometer.analyzeAccountData(AccountAnalyzingBotometer.java:83)
at de.fjobilabs.botometer.AccountAnalyzingBotometer.analyzeAccount(AccountAnalyzingBotometer.java:72)

Exception in thread "main" de.fjobilabs.botometer.BotometerException: Botometer failed to analyze account data

Attempting to go through the test analysis but it says that the error is caused by the API not existing? I'm confused on how to proceed from here.

`package botometerTesting;

import de.fjobilabs.botometer.AccountAnalysisResult;
import de.fjobilabs.botometer.Botometer;
import de.fjobilabs.botometer.BotometerConfiguration;
import de.fjobilabs.botometer.BotometerConfigurationBuilder;
import de.fjobilabs.botometer.BotometerFactory;

import twitter4j.User;
import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
import twitter4j.TwitterException;

public class botoMeterHandler {

static Twitter twitter = TwitterFactory.getSingleton();
static User theUser;

static public final String BotometerAPIKey   = "",
							consumerKey      = "",
							consumerSecret   = "",
							accessToken      = "",
							acessTokenSecret = "";

public static void main (String[] args) throws TwitterException {
	
	BotometerConfiguration config = new BotometerConfigurationBuilder()
		    .botometerApiKey(BotometerAPIKey) // X-RapidAPI-Key
		    .twitterConsumerKey(consumerKey) //consumer-key
		    .twitterConsumerSecret(consumerSecret) //consumer-secret
		    .twitterAccessToken(accessToken) //access-token
		    .twitterAccessTokenSecret(acessTokenSecret) //access-token-secret
		    .build();

	Botometer botometer = new BotometerFactory(config).create();
	
	theUser = twitter.showUser(twitter.getId());
	
	AccountAnalysisResult result = botometer.analyzeAccount(theUser.getScreenName());
}

}
`

And the error is
Screen Shot 2022-05-19 at 9 19 45 PM

Make Botometer API URL configurable (but with default value)

Recently OSoMe changed the API URL at RapidAPI. If this changes again it may be useful for the user to configure the URL themself.

[...] the Botometer URL is hardcoded at the moment:

private static final String BOTOMETER_CHECK_ACCOUNT_URL = "https://osome-botometer.p.rapidapi.com/2/check_account";

We should make the URL configurable through BotometerConfiguration and provide the new URL as a default value.

Originally posted by @fxjordan in #4 (comment)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.