Помогите сформировать POST запрос на мейл ру

lbvf65

Client
Регистрация
20.08.2020
Сообщения
438
Благодарностей
113
Баллы
43
Помогите сформировать запрос

На этот адрес нужно отправить POST запро https://e.mail.ru/api/v1


Referer: https://e.mail.ru/inbox/?filter_unread=1




__urlp=/threads/move?ids=%5B%221%3A116ea134fed8dc6c%3A0%22%5D&msg_ids=%5B%7B%22id%22%3A%221%3A116ea134fed8dc6c%3A0%22%2C%22folder%22%3A%220%22%7D%5D&folder=8&message_id_last=%7B%221%3A116ea134fed8dc6c%3A0%22%3A%2216221272671183833574%22%7D&email=почта &htmlencoded=false&token=3f1d9858edcdf63d8762533b4a3141e8%3A467d5f4f6a02587a190754065d0a09000a515750515f0106510e03070607020a5203500a080c0055091654475c6e4206

не могу понять откуда брать 16221272671183833574

как подставить в правильном формате 116ea134fed8dc6c

не смог сформировать рабочий запрос


или
На этот адрес нужно отправить POST запрос - https://e.mail.ru/api/v1/threads/move

Referer: ссылка на письмо

ids=%5B%220%3A16214059621210602500%3A0%22%5D&msg_ids=%5B%7B%22id%22%3A%220%3A16214059621210602500%3A0%22%2C%22folder%22%3A%220%22%7D%5D&folder=1&message_id_last=%7B%220%3A16214059621210602500%3A0%22%3A%2216214059621210602500%22%7D&email=ваша почта&htmlencoded=false&token=токен

не могу понять откуда брать 16214059621210602500

переносило только 1 письмо с почты не знаю почему

знающие люди тыкните носом уже больше недели не могу это реализовать

простая задача просто переложить письмо POST запросам в нужную папку

помогите кто может:bt:
 

SHILY

Client
Регистрация
05.06.2016
Сообщения
258
Благодарностей
304
Баллы
63
Взял авторизацию, которую тебе уже кидал на форуме. + Набросал, на скорую руку, перенос первого письма из инбокса в спам :-)
Авторизация mail.ru:
/*--------------------------------
        Данные для запроса
*///------------------------------
string _account = "login:password"; // аккаунт через разделитель "login:pass" или "login;pass".
string _proxy = "";

/*----------------------------------------------------
        Авторизация майлру
*///---------------------------------------------------
string _login = String.Empty, _password = String.Empty;
try
{
    _login = _account.Split(':', ';')[0];
    _password = _account.Split(':', ';')[1];

    if (String.IsNullOrWhiteSpace(_login)) throw new Exception("Логин не указан");
    if (String.IsNullOrWhiteSpace(_password)) throw new Exception("Пароль не указан");

    project.Profile.CookieContainer.Clear(); // очистка контейнера куков.

    string HttpResponse = ZennoPoster.HTTP.Request
    (
        ZennoLab.InterfacesLibrary.Enums.Http.HttpMethod.GET, "https://mail.ru/", "", "", _proxy, "UTF-8",
        ZennoLab.InterfacesLibrary.Enums.Http.ResponceType.BodyOnly, 20000, "", project.Profile.UserAgent, true, 5,
        new String[]{},  "", false, false, project.Profile.CookieContainer
    );
    if (String.IsNullOrWhiteSpace(HttpResponse)) throw new Exception("HttpResponse пуст");

    string token = Regex.Match(HttpResponse, "((?<=CSRF:\").*?(?=\")|(?<=CSRF:\\ \").*?(?=\"))").Value; // парсинг токена для авторизации.

    if (String.IsNullOrWhiteSpace(token)) throw new Exception("token для авторизации не найден");

    /*Авторизация*/
    HttpResponse = ZennoPoster.HTTP.Request
    (
        ZennoLab.InterfacesLibrary.Enums.Http.HttpMethod.POST, "https://auth.mail.ru/jsapi/auth",
        $"login={ZennoLab.Macros.TextProcessing.UrlEncode(_login)}&password={ZennoLab.Macros.TextProcessing.UrlEncode(_password)}&saveauth=1&token={token}&project=e.mail.ru&_="
        + Convert.ToString((DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds).Replace(",", "").Substring(0, 13),
        "application/x-www-form-urlencoded", _proxy, "UTF-8",
        ZennoLab.InterfacesLibrary.Enums.Http.ResponceType.HeaderAndBody, 20000, "", project.Profile.UserAgent, true, 5,
        new String[]
        {
            "Accept: */*",
            "Origin: https://mail.ru",
            "Referer: https://mail.ru/",
            "Connection: keep-alive"
        },
        "", false, false, project.Profile.CookieContainer
    );
    if (Regex.IsMatch(HttpResponse, "(?<=\\{\"status\":\")ok.*?(?=\"})"))
    {
        project.Profile.Save($@"{project.Directory}\profiles\{_login}.zpprofile", true, true, true, true, true, true, true, true, true, new string[]{"PROXY"}); // сейв профиля.
        project.SendInfoToLog($"{_login} | Успешная авторизация", true); // лог для zp.
    }
    else
    {
        /*Определение ошибки, если не вышло авторизоваться*/
        if (!Regex.IsMatch(HttpResponse, "((?<=\\{\"status\":\")break.*?(?=\"})|(?<=\"status\":\")fail.*?(?=\"}))")) throw new Exception("Неизвестная ошибка авторизации");
        if (Regex.IsMatch(HttpResponse, "(?<=\\{\"status\":\")break.*?(?=\"})")) throw new Exception("Требуется SMS подтверждение/Восстановление доступа");
        if (Regex.IsMatch(HttpResponse, "(?<=\"status\":\")fail.*?(?=\"})")) throw new Exception("Не верный логин или пароль");
    }
}
catch (Exception ex)
{
    project.SendWarningToLog(!String.IsNullOrWhiteSpace(_login) ? $"{_login} | {ex.Message}" : $"{ex.Message}", true);
}
Перенос письма из inbox в spam:
/*--------------------------------
        Данные для запросов
*///------------------------------
var email = "[email protected]";
var proxy = "";

/*--------------------------------
        Перенос письма
*///------------------------------
string httpResponse = string.Empty, idMessage = string.Empty, expandMessage = string.Empty;

// Запрос для получения токена
string GetToken(string url)
{
    return ZennoPoster.HTTP.Request
    (
        method: ZennoLab.InterfacesLibrary.Enums.Http.HttpMethod.GET,
        respType: ZennoLab.InterfacesLibrary.Enums.Http.ResponceType.BodyOnly,
        url: url,
        UserAgent: project.Profile.UserAgent, proxy: proxy, Encoding: "utf-8", Timeout: 30000, UseRedirect: true, MaxRedirectCount: 5,
        cookieContainer: project.Profile.CookieContainer
    );   
};

// Делаем запрос для получение токена
httpResponse = GetToken("https://e.mail.ru/inbox/");

// Чекаем на редирект (если нужно, то делаем запрос с доп. параметром)
if (Regex.IsMatch(httpResponse, @"(?<=')&afterReload=1.*?(?=';)")) httpResponse = GetToken("https://e.mail.ru/inbox/?afterReload=1");

// Парсим токен
var token = Regex.Match(httpResponse, "(?<=\"token\":\").*?(?=\")|(?<=updateToken\\(\").*?(?=\")").Value;

// Чекаем на наличие токена
if (string.IsNullOrWhiteSpace(token))
{
    project.SendToLog("Токен не найден", ZennoLab.InterfacesLibrary.Enums.Log.LogType.Warning, true, ZennoLab.InterfacesLibrary.Enums.Log.LogColor.Yellow);
    return null;
}

// Получаем список писем
httpResponse = ZennoPoster.HTTP.Request
(
    method: ZennoLab.InterfacesLibrary.Enums.Http.HttpMethod.GET,
    respType: ZennoLab.InterfacesLibrary.Enums.Http.ResponceType.BodyOnly,
    url: $"https://e.mail.ru/api/v1/threads/status/smart?folder=0&limit=50&filters=%7B%7D&last_modified=1&force_custom_thread=true&supported_custom_metathreads=[%22tomyself%22]&pinned_limit=50&offset=0&email={ZennoLab.Macros.TextProcessing.UrlEncode(email)}&htmlencoded=false&token={token}&_={((DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds).ToString().Replace(".", "").Substring(0, 13)}",
    UserAgent: project.Profile.UserAgent, proxy: proxy, Encoding: "utf-8", Timeout: 30000, UseRedirect: true, MaxRedirectCount: 5,
    cookieContainer: project.Profile.CookieContainer
);

try
{
    // Парсим json
    project.Json.FromString(httpResponse);
   
    // Получаем нужные параметры письма для переноса
    idMessage = project.Json.body.threads[0].id;
    expandMessage = project.Json.body.threads[0].expand;
}
catch (Exception ex)
{
    project.SendToLog($"ExceptionMessage: {ex.Message}", ZennoLab.InterfacesLibrary.Enums.Log.LogType.Warning, true, ZennoLab.InterfacesLibrary.Enums.Log.LogColor.Yellow);
    return null;
}

// Чекаем полученные параметры
if (new[]{idMessage, expandMessage}.Any(x => string.IsNullOrWhiteSpace(x))) throw new Exception("Не найдены идентификаторы письма");

project.SendToLog($"Message ID: {idMessage} | Message Expand: {expandMessage}", ZennoLab.InterfacesLibrary.Enums.Log.LogType.Info, true, ZennoLab.InterfacesLibrary.Enums.Log.LogColor.Blue);

// Формирование контента
var content = new[]
{
    "ids=" + ZennoLab.Macros.TextProcessing.UrlEncode($"[\"{idMessage}\"]"),
    "&msg_ids=" + ZennoLab.Macros.TextProcessing.UrlEncode($"[{{\"id\":\"{idMessage}\",\"folder\":\"0\"}}]"),
    "&folder=950",
    "&message_id_last=" + ZennoLab.Macros.TextProcessing.UrlEncode($"{{\"{idMessage}\":\"{expandMessage}\"}}"),
    "&email=" + ZennoLab.Macros.TextProcessing.UrlEncode(email),
    "&htmlencoded=false",
    "&token=" + ZennoLab.Macros.TextProcessing.UrlEncode(token)
};

// Перенос письма
httpResponse = ZennoPoster.HTTP.Request
(
    method: ZennoLab.InterfacesLibrary.Enums.Http.HttpMethod.POST,
    respType: ZennoLab.InterfacesLibrary.Enums.Http.ResponceType.BodyOnly,
    url: "https://e.mail.ru/api/v1/threads/move",
    contentPostingType: "application/x-www-form-urlencoded",
    content: string.Join("", content),   
    UserAgent: project.Profile.UserAgent, proxy: proxy, Encoding: "utf-8", Timeout: 30000, UseRedirect: true, MaxRedirectCount: 5,
    cookieContainer: project.Profile.CookieContainer
);

// Чекаем результат переноса
if (Regex.IsMatch(httpResponse, "(?<=\"status\":)200.*?(?=,)"))
{
    project.SendToLog("Письмо перенесено успешно", ZennoLab.InterfacesLibrary.Enums.Log.LogType.Info, true, ZennoLab.InterfacesLibrary.Enums.Log.LogColor.Green);
}
else
{
    project.SendToLog("Не удалось перенести письмо", ZennoLab.InterfacesLibrary.Enums.Log.LogType.Info, true, ZennoLab.InterfacesLibrary.Enums.Log.LogColor.Yellow);
}
78053
 
Последнее редактирование:
  • Спасибо
Реакции: dimafatality и lbvf65

lbvf65

Client
Регистрация
20.08.2020
Сообщения
438
Благодарностей
113
Баллы
43
Взял авторизацию, которую тебе уже кидал на форуме. + Набросал, на скорую руку, перенос первого письма из инбокса в спам :-)
Авторизация mail.ru:
/*--------------------------------
        Данные для запроса
*///------------------------------
string _account = "login:password"; // аккаунт через разделитель "login:pass" или "login;pass".
string _proxy = "";

/*----------------------------------------------------
        Авторизация майлру
*///---------------------------------------------------
string _login = String.Empty, _password = String.Empty;
try
{
    _login = _account.Split(':', ';')[0];
    _password = _account.Split(':', ';')[1];

    if (String.IsNullOrWhiteSpace(_login)) throw new Exception("Логин не указан");
    if (String.IsNullOrWhiteSpace(_password)) throw new Exception("Пароль не указан");

    project.Profile.CookieContainer.Clear(); // очистка контейнера куков.

    string HttpResponse = ZennoPoster.HTTP.Request
    (
        ZennoLab.InterfacesLibrary.Enums.Http.HttpMethod.GET, "https://mail.ru/", "", "", _proxy, "UTF-8",
        ZennoLab.InterfacesLibrary.Enums.Http.ResponceType.BodyOnly, 20000, "", project.Profile.UserAgent, true, 5,
        new String[]{},  "", false, false, project.Profile.CookieContainer
    );
    if (String.IsNullOrWhiteSpace(HttpResponse)) throw new Exception("HttpResponse пуст");

    string token = Regex.Match(HttpResponse, "((?<=CSRF:\").*?(?=\")|(?<=CSRF:\\ \").*?(?=\"))").Value; // парсинг токена для авторизации.

    if (String.IsNullOrWhiteSpace(token)) throw new Exception("token для авторизации не найден");

    /*Авторизация*/
    HttpResponse = ZennoPoster.HTTP.Request
    (
        ZennoLab.InterfacesLibrary.Enums.Http.HttpMethod.POST, "https://auth.mail.ru/jsapi/auth",
        $"login={ZennoLab.Macros.TextProcessing.UrlEncode(_login)}&password={ZennoLab.Macros.TextProcessing.UrlEncode(_password)}&saveauth=1&token={token}&project=e.mail.ru&_="
        + Convert.ToString((DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds).Replace(",", "").Substring(0, 13),
        "application/x-www-form-urlencoded", _proxy, "UTF-8",
        ZennoLab.InterfacesLibrary.Enums.Http.ResponceType.HeaderAndBody, 20000, "", project.Profile.UserAgent, true, 5,
        new String[]
        {
            "Accept: */*",
            "Origin: https://mail.ru",
            "Referer: https://mail.ru/",
            "Connection: keep-alive"
        },
        "", false, false, project.Profile.CookieContainer
    );
    if (Regex.IsMatch(HttpResponse, "(?<=\\{\"status\":\")ok.*?(?=\"})"))
    {
        project.Profile.Save($@"{project.Directory}\profiles\{_login}.zpprofile", true, true, true, true, true, true, true, true, true, new string[]{"PROXY"}); // сейв профиля.
        project.SendInfoToLog($"{_login} | Успешная авторизация", true); // лог для zp.
    }
    else
    {
        /*Определение ошибки, если не вышло авторизоваться*/
        if (!Regex.IsMatch(HttpResponse, "((?<=\\{\"status\":\")break.*?(?=\"})|(?<=\"status\":\")fail.*?(?=\"}))")) throw new Exception("Неизвестная ошибка авторизации");
        if (Regex.IsMatch(HttpResponse, "(?<=\\{\"status\":\")break.*?(?=\"})")) throw new Exception("Требуется SMS подтверждение/Восстановление доступа");
        if (Regex.IsMatch(HttpResponse, "(?<=\"status\":\")fail.*?(?=\"})")) throw new Exception("Не верный логин или пароль");
    }
}
catch (Exception ex)
{
    project.SendWarningToLog(!String.IsNullOrWhiteSpace(_login) ? $"{_login} | {ex.Message}" : $"{ex.Message}", true);
}
Перенос письма из inbox в spam:
/*--------------------------------
        Данные для запроса
*///------------------------------
var email = "[email protected]";
var proxy = "";

/*--------------------------------
        Перенос письма
*///------------------------------
var unixTime = ((DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds).ToString().Replace(".", "").Substring(0, 13);

var httpResponse = ZennoPoster.HTTP.Request
(
    method: ZennoLab.InterfacesLibrary.Enums.Http.HttpMethod.GET,
    respType: ZennoLab.InterfacesLibrary.Enums.Http.ResponceType.BodyOnly,
    url: "https://e.mail.ru/inbox/",
    UserAgent: project.Profile.UserAgent, proxy: proxy, Encoding: "utf-8", Timeout: 30000, UseRedirect: true, MaxRedirectCount: 5,
    cookieContainer: project.Profile.CookieContainer
);

if (Regex.IsMatch(httpResponse, @"(?<=')&afterReload=1.*?(?=';)"))
{
    httpResponse = ZennoPoster.HTTP.Request
    (
        method: ZennoLab.InterfacesLibrary.Enums.Http.HttpMethod.GET,
        respType: ZennoLab.InterfacesLibrary.Enums.Http.ResponceType.BodyOnly,
        url: "https://e.mail.ru/inbox/?afterReload=1",
        UserAgent: project.Profile.UserAgent, proxy: proxy, Encoding: "utf-8", Timeout: 30000, UseRedirect: true, MaxRedirectCount: 5,
        cookieContainer: project.Profile.CookieContainer
    );
}

var token = Regex.Match(httpResponse, "(?<=\"token\":\").*?(?=\")|(?<=updateToken\\(\").*?(?=\")").Value;

if (string.IsNullOrWhiteSpace(token)) throw new Exception("Токен не найден");

httpResponse = ZennoPoster.HTTP.Request
(
    method: ZennoLab.InterfacesLibrary.Enums.Http.HttpMethod.GET,
    respType: ZennoLab.InterfacesLibrary.Enums.Http.ResponceType.BodyOnly,
    url: $"https://e.mail.ru/api/v1/threads/status/smart?folder=0&limit=50&filters=%7B%7D&last_modified=1&force_custom_thread=true&supported_custom_metathreads=[%22tomyself%22]&pinned_limit=50&offset=0&email={ZennoLab.Macros.TextProcessing.UrlEncode(email)}&htmlencoded=false&token={token}&_={unixTime}",
    UserAgent: project.Profile.UserAgent, proxy: proxy, Encoding: "utf-8", Timeout: 30000, UseRedirect: true, MaxRedirectCount: 5,
    cookieContainer: project.Profile.CookieContainer
);

project.Json.FromString(httpResponse);

var idMessage = project.Json.body.threads[0].id;
var expandMessage = project.Json.body.threads[0].expand;

if (new[]{idMessage, expandMessage}.Any(x => string.IsNullOrWhiteSpace(x))) throw new Exception("Не найдены идентификаторы письма");

project.SendInfoToLog(idMessage);
project.SendInfoToLog(expandMessage);

var content = "ids=" + ZennoLab.Macros.TextProcessing.UrlEncode($"[\"{idMessage}\"]") +
    "&msg_ids=" + ZennoLab.Macros.TextProcessing.UrlEncode($"[{{\"id\":\"{idMessage}\",\"folder\":\"0\"}}]") +
    "&folder=950" +
    "&message_id_last=" + ZennoLab.Macros.TextProcessing.UrlEncode($"{{\"{idMessage}\":\"{expandMessage}\"}}") +
    "&email=" + ZennoLab.Macros.TextProcessing.UrlEncode(email) +
    "&htmlencoded=false" +
    "&token=" + ZennoLab.Macros.TextProcessing.UrlEncode(token);

project.SendInfoToLog(content);

httpResponse = ZennoPoster.HTTP.Request
(
    method: ZennoLab.InterfacesLibrary.Enums.Http.HttpMethod.POST,
    respType: ZennoLab.InterfacesLibrary.Enums.Http.ResponceType.BodyOnly,
    url: "https://e.mail.ru/api/v1/threads/move",
    contentPostingType: "application/x-www-form-urlencoded",
    content: content,
    UserAgent: project.Profile.UserAgent, proxy: proxy, Encoding: "utf-8", Timeout: 30000, UseRedirect: true, MaxRedirectCount: 5,
    cookieContainer: project.Profile.CookieContainer
);

if (Regex.IsMatch(httpResponse, "(?<=\"status\":)200.*?(?=,)"))
{
    project.SendToLog("Письмо перенесено успешно", ZennoLab.InterfacesLibrary.Enums.Log.LogType.Info, true, ZennoLab.InterfacesLibrary.Enums.Log.LogColor.Green);
}
else
{
    project.SendToLog("Не удалось перенести письмо", ZennoLab.InterfacesLibrary.Enums.Log.LogType.Info, true, ZennoLab.InterfacesLibrary.Enums.Log.LogColor.Yellow);
}
Посмотреть вложение 78053



авторизация работает а
Перенос письма из inbox в spam:

выдает ошибку

Выполнение действия CSharp OwnCode. "ZennoLab.JXParser.JsonDynamic" не содержит определения для "id"

Как устранить ошибку ?
 
Последнее редактирование:

SHILY

Client
Регистрация
05.06.2016
Сообщения
258
Благодарностей
304
Баллы
63
выдает ошибку
Выполнение действия CSharp OwnCode. "ZennoLab.JXParser.JsonDynamic" не содержит определения для "id"
Это значит, что он не нашел переменную после распарса json.
Проверь правильность заполнения, может ты свой ящик не указал.
78064
Ибо я сейчас специально проверил ещё на одном акке и всё норм.
78065
Если не в этом дело, то уже смотри монитор трафика.


UPD: У кого будет похожая ошибка - проверьте свой индекс id, он может отличаться.
 
Последнее редактирование:

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)