我无法使用xNet在noip.com上创建主机名

时间:2018-07-28 20:28:22

标签: c# httprequest xnet

我无法使用xNet在noip.com上创建主机名。我的发布操作将重定向到登录页面。这就是为什么?

using (var req = new HttpRequest())
{
    req.UserAgent = "Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 950) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Mobile Safari/537.36 Edge/13.10586";
    CookieDictionary _cookie = new CookieDictionary(false);
    req.Cookies = _cookie;
    req.AddHeader("Accept-Language", "vi-VN,vi;q=0.8,en-US;q=0.5,en;q=0.3");
    req.AddHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
    req.CharacterSet = Encoding.UTF8;
    req.Referer = "https://www.noip.com/";
    req.KeepAlive = true;
    string input = "";
    string value = "";
    input = req.Get("https://www.noip.com/login", null).ToString();
    value = Regex.Match(input, "name=\"csrf-token\" content=\"(.*?)\"").Groups[1].Value;
    string param = string.Concat(new object[]
        {
            "_token=",
            value,
            "&username=fxnzpkg4hzm@johnpo.gq&password=cuongdzvlne&submit_login_page=1&_token=",
            value,
            "&Login"
        });

    // Login noip.com
    input = req.Post("https://www.noip.com/login", param, "application/x-www-form-urlencoded").ToString();
    req.Referer = "https://my.noip.com/";
    req.AddHeader("Origin", "https://my.noip.com");
    req.AddHeader("Accept", "application/json");
    param = "{\"id\":0,\"target\":\"45.77.254.222\",\"name\":\"" + Path.GetRandomFileName().Replace(".", "") + "\",\"domain\":\"zapto.org\",\"wildcard\":false,\"type\":\"A\",\"ipv6\":\"\",\"url\":{\"scheme\":\"http\",\"is_masq\":false,\"masq_title\":\"\",\"meta_desc\":\"\",\"meta_keywords\":\"\"},\"is_offline\":false,\"offline_settings\":{\"action\":\"noop\",\"ip\":\"\",\"url\":\"\",\"protocol\":\"http\",\"page\":{\"title\":\"\",\"image_url\":\"\",\"text\":\"\",\"email\":\"\"}},\"mx_records\":[]}";
    req.AddHeader("Content-Length", Convert.ToString(Encoding.UTF8.GetBytes(param).Length));

    // Create hostname
    input = req.Post("https://my.noip.com/api/host", param, "application/json").ToString();
    File.AppendAllText("kq.html", input);
    if (input.Contains("https://www.noip.com/login"))
    {
        MessageBox.Show("-------------- Error");
    }
    else
    {
        MessageBox.Show("-------------- OK");
    }
}

0 个答案:

没有答案