Search in sources :

Example 6 with ErrorInterceptor

use of me.postaddict.instagram.scraper.interceptor.ErrorInterceptor in project instagram-java-scraper by postaddictme.

the class InstagramFactory method getAuthenticatedInstagramClient.

public static Instagram getAuthenticatedInstagramClient(String login, String password, String userAgent) throws IOException {
    OkHttpClient httpClient = new OkHttpClient.Builder().addInterceptor(new UserAgentInterceptor(userAgent)).addInterceptor(new ErrorInterceptor()).cookieJar(new DefaultCookieJar(new CookieHashSet())).build();
    Instagram client = new Instagram(httpClient);
    client.basePage();
    client.login(login, password);
    client.basePage();
    return client;
}
Also used : CookieHashSet(me.postaddict.instagram.scraper.cookie.CookieHashSet) OkHttpClient(okhttp3.OkHttpClient) ErrorInterceptor(me.postaddict.instagram.scraper.interceptor.ErrorInterceptor) UserAgentInterceptor(me.postaddict.instagram.scraper.interceptor.UserAgentInterceptor) DefaultCookieJar(me.postaddict.instagram.scraper.cookie.DefaultCookieJar)

Aggregations

ErrorInterceptor (me.postaddict.instagram.scraper.interceptor.ErrorInterceptor)6 UserAgentInterceptor (me.postaddict.instagram.scraper.interceptor.UserAgentInterceptor)6 OkHttpClient (okhttp3.OkHttpClient)6 CookieHashSet (me.postaddict.instagram.scraper.cookie.CookieHashSet)5 DefaultCookieJar (me.postaddict.instagram.scraper.cookie.DefaultCookieJar)5 HttpLoggingInterceptor (okhttp3.logging.HttpLoggingInterceptor)5 BeforeClass (org.junit.BeforeClass)4 Test (org.junit.Test)1