Open blaketanon opened 6 years ago
Please use to provide more information
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.HEADERS);
OkHttpClient httpClient = new OkHttpClient.Builder()
.addNetworkInterceptor(loggingInterceptor)
.addInterceptor(new UserAgentInterceptor(UserAgents.OSX_CHROME))
.addInterceptor(new ErrorInterceptor())
.cookieJar(new DefaultCookieJar(new CookieHashSet()))
.build();
client = new Instagram(httpClient);
client.basePage();
client.login(credentials.getLogin(), credentials.getPassword());
client.basePage();
Thank you Igor, please see below log.
--> GET https://www.instagram.com/ http/1.1 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36 Host: www.instagram.com Connection: Keep-Alive Accept-Encoding: gzip --> END GET <-- 200 OK https://www.instagram.com/ (76ms) Content-Type: text/html X-Frame-Options: SAMEORIGIN Set-Cookie: sessionid=; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/; HttpOnly; Domain=instagram.com Vary: Cookie, Accept-Language, Accept-Encoding Cache-Control: private, no-cache, no-store, must-revalidate Pragma: no-cache Expires: Sat, 01 Jan 2000 00:00:00 GMT Content-Language: en Content-Encoding: gzip Date: Wed, 17 Jan 2018 18:52:12 GMT Strict-Transport-Security: max-age=86400 Set-Cookie: csrftoken=hsumRncAtr2eHH3X6DW82GC2PFrrYWxj; expires=Wed, 16-Jan-2019 18:52:12 GMT; Max-Age=31449600; Path=/; Secure Set-Cookie: rur=ATN; Path=/ Set-Cookie: mid=Wl-bXAAEAAFYlmvNjEnxtdzznZuU; expires=Tue, 12-Jan-2038 18:52:12 GMT; Max-Age=630720000; Path=/ Connection: keep-alive Content-Length: 4600 OkHttp-Sent-Millis: 1516215132299 OkHttp-Received-Millis: 1516215132374 <-- END HTTP --> POST https://www.instagram.com/accounts/login/ajax/ http/1.1 Content-Type: application/x-www-form-urlencoded Content-Length: 40 Referer: https://www.instagram.com/ X-CSRFToken: hsumRncAtr2eHH3X6DW82GC2PFrrYWxj User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36 Host: www.instagram.com Connection: Keep-Alive Accept-Encoding: gzip Cookie: csrftoken=hsumRncAtr2eHH3X6DW82GC2PFrrYWxj; rur=ATN; mid=Wl-bXAAEAAFYlmvNjEnxtdzznZuU --> END POST <-- 500 Internal Server Error https://www.instagram.com/accounts/login/ajax/ (1556ms) Content-Type: text/html; charset=utf-8 Vary: Cookie, Accept-Language Exception in thread "main" Cache-Control: private, no-cache, no-store, must-revalidate Pragma: no-cache Expires: Sat, 01 Jan 2000 00:00:00 GMT Content-Language: en Date: Wed, 17 Jan 2018 18:52:14 GMT Strict-Transport-Security: max-age=86400 Set-Cookie: csrftoken=2Po12cEBvOOTJqdLBJty4KKtqSCbpI3C; expires=Wed, 16-Jan-2019 18:52:14 GMT; Max-Age=31449600; Path=/; Secure Set-Cookie: rur=ATN; Path=/ Connection: keep-alive Content-Length: 25 OkHttp-Sent-Millis: 1516215132642 OkHttp-Received-Millis: 1516215134199 <-- END HTTP me.postaddict.instagram.scraper.exception.InstagramException: Response code is not equal 200. Something went wrong. Please report issue. at me.postaddict.instagram.scraper.interceptor.ErrorInterceptor.intercept(ErrorInterceptor.java:31) at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:187) at me.postaddict.instagram.scraper.interceptor.UserAgentInterceptor.intercept(UserAgentInterceptor.java:27) at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:187) at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:160) at okhttp3.RealCall.execute(RealCall.java:57) at me.postaddict.instagram.scraper.Instagram.executeHttpRequest(Instagram.java:253) at me.postaddict.instagram.scraper.Instagram.login(Instagram.java:72) at me.Main.main(Main.java:53)
It appears to work if i change the login endpoint to https://www.instagram.com/accounts/login/ajax/?force_classic_login
So with that I get past the login, but now I'm stuck with Instagram.likeMediaByCode(). I login, run a code through here with no result or error - the URl it is making does not work when i paste it in a browser
I'm getting the following error when using the Login(username,password) method on Instagram Class.
Exception in thread "main" com.fasterxml.jackson.core.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') at [Source: (okio.RealBufferedSource$1); line: 1, column: 2] at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1798) at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:663) at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:561) at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._handleUnexpectedValue(UTF8StreamJsonParser.java:2625) at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._nextTokenNotInObject(UTF8StreamJsonParser.java:826) at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.nextToken(UTF8StreamJsonParser.java:723) at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:4129) at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3988) at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3065) at me.postaddict.instagram.scraper.mapper.ModelMapper.isAuthenticated(ModelMapper.java:136) at me.postaddict.instagram.scraper.Instagram.login(Instagram.java:74)