Updates on this library?
Hello, are there any updates on this library? ì I have seen it has been called a continuation of Instagram4J but I cannot make it work
https://gist.github.com/nicecraftz/287ffd4e3437ac8b96f26cd86d4a0455
I am getting this error just when creating the instance of JxInsta with valid credentials.
Exception in thread "main" java.lang.IndexOutOfBoundsException: Empty list doesn't contain element at index 0. at kotlin.collections.EmptyList.get(Collections.kt:36) at kotlin.collections.EmptyList.get(Collections.kt:24) at com.errorxcode.jxinsta.Utils.getCrsf(Utils.java:100) at com.errorxcode.jxinsta.JxInsta.<init>(JxInsta.java:71) at it.alessandrocalista.Main.main(Main.java:22)
Is it happening only in WEB_AUTHENTICATION mode?
Really sorry for the no reply about this issue, will try tomorrow if i happen to remember it, lol.
sorry again.
It's okey, lemme know
It's okey, lemme know
totally forgot about this once again, i will try in the morning, just put it into my calendar to remember it, lol.
Hallo, sorry for the long awaited response
public static void main(String[] args) {
try {
JxInsta insta = new JxInsta(
"#####",
"#####",
JxInsta.LoginType.BOTH_WEB_AND_APP_AUTHENTICATION
);
File file = new File("test.jpg");
insta.uploadStory(file);
} catch (IOException | InstagramException e) {
throw new RuntimeException(e);
}
System.out.println("Hello, World!");
}
This is my current snippet, it should publish a story with the following test.jpg image but instead its giving me out this error.
Exception in thread "main" java.lang.IndexOutOfBoundsException: Empty list doesn't contain element at index 0.
at kotlin.collections.EmptyList.get(Collections.kt:36)
at kotlin.collections.EmptyList.get(Collections.kt:24)
at com.errorxcode.jxinsta.Utils.getCrsf(Utils.java:100)
at com.errorxcode.jxinsta.JxInsta.<init>(JxInsta.java:71)
at com.errorxcode.jxinsta.JxInsta.<init>(JxInsta.java:77)
at it.alessandrocalista.instagram.Main.main(Main.java:12)
Change the LoginType to WEB_AUTH and try again, after that change it to MOBILE_AUTH and try again. Let me know the error in both cases
I also get the same issue (exact same stack). I've tried all available auth types.
Alright, Please wait for the update!
Its the Utils.getCrsf() function just replace it with
protected static String getCrsf() throws IOException {
Request request = new Request.Builder()
.url("https://www.instagram.com/")
.addHeader("user-agent", Constants.WEB_USER_AGENT)
.addHeader("accept", "*/*")
.addHeader("accept-language", "en-US,en;q=0.9")
.addHeader("x-requested-with", "XMLHttpRequest")
.get()
.build();
try (Response response = client.newCall(request).execute()) {
List<String> cookies = response.headers("Set-Cookie");
for (String cookie : cookies) {
if (cookie.startsWith("csrftoken=")) {
return cookie.split(";")[0].split("=")[1];
}
}
throw new IOException("csrftoken not found in cookies");
}
}
But I have already sent the main author a request to merge my enhancements for this library.
Thank you for drawing attention to the issue. I'll counter this in the new release (Coming soon)