All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
ir.sadeghpro.insta.client.Test Maven / Gradle / Ivy
package ir.sadeghpro.insta.client;
import com.afollestad.ason.Ason;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Test {
public static void main(String[] args) throws IOException {
// Connection.Response r = Jsoup.connect("http://www.spadsms.ir/test.php").method(Connection.Method.POST).data("test","12221").execute();
// System.out.println(r.body());
try {
Insta insta = new Insta();
Ason json = insta.login("sadeghmkhan2","peter6220");
String status = json.getString("status","");
assert status != null;
if(status.equals("fail")){
if(json.has("checkpoint_url")){
Connection.Response r = Jsoup.connect(S.URL + "challenge/reset" + json.getString("checkpoint_url").replace("challenge/",""))
.method(Connection.Method.POST).header("X-CSRFToken",insta.getCsrf())
.header("X-Instagram-AJAX",insta.getRollOutHash()).cookies(insta.getCookie()).userAgent(insta.getUserAgent()).ignoreContentType(true).execute();
Ason object = new Ason(r.body());
// System.out.println("---------------");
insta.getCookie().forEach((k,v)-> System.out.println(k+":"+v));
for (Map.Entry entry : r.cookies().entrySet()) {
// System.out.println(entry.getKey() +":"+entry.getValue() +"::::::::::::");
if (entry.getValue().isEmpty() || entry.getValue().equals("\"\"")) {
insta.getCookie().remove(entry.getKey());
} else {
insta.getCookie().put(entry.getKey(), entry.getValue());
}
}
// if(object.has("fields.phone_number"))
r = Jsoup.connect(S.URL + "challenge/reset" + json.getString("checkpoint_url").replace("challenge/",""))
.method(Connection.Method.POST).data("choice",object.getString("fields.choice")).cookies(insta.getCookie()).header("X-CSRFToken",insta.getCsrf())
.header("X-Instagram-AJAX",insta.getRollOutHash()).userAgent(insta.getUserAgent()).ignoreContentType(true).execute();
System.out.println(r.body());
// Thread.sleep(1000);
// System.out.println("---------------");
// insta.getCookie().forEach((k,v)-> System.out.println(k+":"+v));
for (Map.Entry entry : r.cookies().entrySet()) {
if (entry.getValue().isEmpty() || entry.getValue().equals("\"\"")) {
insta.getCookie().remove(entry.getKey());
} else {
insta.getCookie().put(entry.getKey(), entry.getValue());
}
}
// System.out.println("---------------");
// insta.getCookie().forEach((k,v)-> System.out.println(k+":"+v));
// System.out.println("---------------");
System.out.println("Enter your username: ");
Scanner scanner = new Scanner(System.in);
String username = scanner.nextLine();
System.out.println(insta.getUserAgent());
Map headers = new HashMap<>();
headers.put("origin", "https://www.instagram.com");
headers.put("Host", "www.instagram.com");
headers.put("Content-Type", "application/x-www-form-urlencoded");
headers.put("X-CSRFToken", insta.getCsrf());
headers.put("X-Instagram-AJAX", insta.getRollOutHash());
headers.put("X-Requested-With", "XMLHttpRequest");
headers.put("Accept", "*/*");
headers.put("Accept-Encoding", "gzip, deflate, br");
headers.put("Accept-Language", "en-US,en;q=0.9");
headers.put("Content-Length", "20");
headers.put("Pragma","no-cache");
headers.put("DNT","1");
String url = S.URL + "challenge/" + json.getString("checkpoint_url").replace("/challenge/","");
// Form form = new Form();
// form.add("security_code",username);
// Bridge.post(url).body(form
r = Jsoup.connect(url).headers(headers).referrer(url).method(Connection.Method.POST).data("security_code",username).cookies(insta.getCookie())
.userAgent(insta.getUserAgent()).ignoreContentType(true).ignoreHttpErrors(true).execute();
System.out.println(r.body());
}
}
// System.out.println(insta.isLogin());
// System.out.println(insta.getYourSelf(true));
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
}