Search code examples
javaproxytwitter4j

Proxy configuration in Twitter4j


I am behind a proxy. I have the proxy details. However I am not sure how to use these details to connect to twitter.

I have looked at the documentations so I am aware of the methods:

setHttpProxy(java.lang.String proxyHost, int proxyPort) void setHttpProxyAuth(java.lang.String proxyUser, java.lang.String proxyPass)

But it is not possible to use them as, Eclipse draws a red line underneath them. Do I need to import or initialise anything before using these methods?


Solution

  • Could you try adding the properties

    http.proxyHost=yourProxyHost
    http.proxyPort=yourProxyPort
    

    to the twitter4j.properties ?

    More about properties for twitter4j at http://twitter4j.org/en/configuration.html

    Note that twitter4j lacks proxy-support in versions earlier then 2.1.4 ref this thread: Twitter4j HTTPClient ProxyServer and Java

    Hope it helps :)