private inner class RequestInstagramAPI : AsyncTask<Void, String, String>() {
var activity: Activity? = null
override fun doInBackground(vararg params: Void): String? {
val httpClient = DefaultHttpClient()
val httpGet = HttpGet("https://i.instagram.com/api/v1/feed/reels_tray/")
httpGet.addHeader("Content-Type", "application/x-www-form-urlencoded")
val cookieStore = BasicCookieStore()
val cookie = BasicClientCookie("ds_user_id", "user_id")
val cookie2 = BasicClientCookie("sessionid", "my_session_id")
cookieStore.addCookie(cookie)
cookieStore.addCookie(cookie2)
httpClient.cookieStore = cookieStore
//val cookies = httpClient.cookieStore.cookies
try {
val response = httpClient.execute(httpGet)
val httpEntity = response.entity
return EntityUtils.toString(httpEntity)
} catch (e: IOException) {
e.printStackTrace()
}
return null
}
override fun onPostExecute(response: String?) {
super.onPostExecute(response)
if (response != null) {
try {
} catch (e: JSONException) {
e.printStackTrace()
}
} else {
val toast = Toast.makeText(applicationContext, "Ошибка входа!", Toast.LENGTH_LONG)
toast.show()
}
}
}
我正在得到回复
<!DOCTYPE html>
<html lang="en" class="no-js not-logged-in client-root">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>
Login • Instagram
</title>