Skip to content

Commit fe85f17

Browse files
authored
version 2.9
1 parent ae167a2 commit fe85f17

20 files changed

+1507
-4
lines changed

EasyInsta/build.gradle

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
plugins {
2+
id 'java-library'
3+
}
4+
5+
java {
6+
sourceCompatibility = JavaVersion.VERSION_16
7+
targetCompatibility = JavaVersion.VERSION_16
8+
}
9+
10+
dependencies {
11+
12+
implementation files('libs/instagram4j-realtime.jar')
13+
implementation 'org.jetbrains:annotations:15.0'
14+
implementation 'com.github.instagram4j:instagram4j:2.0.7'
15+
implementation 'com.github.ErrorxCode:JSON-java-port:20220320'
16+
api project(':AsyncTask')
17+
}
2.14 MB
Binary file not shown.
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.xcoder.easyinsta">
4+
5+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.xcoder.easyinsta;
2+
3+
import java.io.IOException;
4+
import java.util.ArrayList;
5+
import java.util.Date;
6+
import java.util.List;
7+
8+
import okhttp3.FormBody;
9+
import okhttp3.MediaType;
10+
import okhttp3.OkHttpClient;
11+
import okhttp3.Request;
12+
import okhttp3.Response;
13+
import port.org.json.JSONObject;
14+
15+
public class HiddenAPI {
16+
17+
protected static List<String> login(String username, String password, boolean isDesktop) throws IOException {
18+
password = "#PWD_INSTAGRAM_BROWSER:0:" + new Date().getTime() + ":" + password;
19+
OkHttpClient client = new OkHttpClient().newBuilder().build();
20+
var body = new FormBody.Builder()
21+
.add("enc_password",password)
22+
.add("username",username)
23+
.add("queryParams","{}")
24+
.build();
25+
Request request = new Request.Builder()
26+
.url("https://www.instagram.com/api/v1/web/accounts/login/ajax/")
27+
.method("POST", body)
28+
.addHeader("authority", "www.instagram.com")
29+
.addHeader("accept", "*/*")
30+
.addHeader("content-type", "application/x-www-form-urlencoded")
31+
.addHeader("x-csrftoken",isDesktop ? getCrsf() : "")
32+
.addHeader("user-agent", isDesktop ? "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36" : "Instagram 219.0.0.12.117 Android")
33+
.build();
34+
Response response = client.newCall(request).execute();
35+
return response.headers("set-cookie");
36+
}
37+
38+
protected static String getCrsf() throws IOException {
39+
OkHttpClient client = new OkHttpClient().newBuilder().build();
40+
MediaType mediaType = MediaType.parse("text/plain");
41+
Request request = new Request.Builder()
42+
.url("https://www.instagram.com/api/v1/web/login_page/")
43+
.addHeader("authority", "www.instagram.com")
44+
.addHeader("accept", "application/json")
45+
.get()
46+
.build();
47+
Response response = client.newCall(request).execute();
48+
return response.headers("Set-Cookie").get(0).split(";")[0].split("=")[1];
49+
}
50+
51+
protected static String getCookieFromHeaders(List<String> headers){
52+
String cookie = "";
53+
for (String header : headers) {
54+
var crsf = header.split(";")[0];
55+
cookie += crsf + ";";
56+
}
57+
return cookie.replaceFirst(".$","");
58+
}
59+
}

0 commit comments

Comments
 (0)