【问题标题】:Whatsapp API old_version errorWhatsapp API old_version 错误
【发布时间】:2018-08-08 20:04:42
【问题描述】:

我一直在尝试让我的 whatsapp 控制台应用程序正常工作。不幸的是,在尝试注册时出现错误:old_version。 这是我的程序在控制台中记录的内容(程序代码如下):

Succesfully connected...
Failed to log in...
  Reason: Auth response error
Phone number validation:
Type "y" in the console if you want to get a validation code send via SMS
y
SMS code send
Error with sending the request...
Reason: {"login":"mynumber","status":"fail","reason":"old_version"}

有人知道如何更新 whatsapp API 吗?它是我的 NuGet 包管理器中当前的最新版本。我知道有两个版本,我都试过了,都没有成功。

我正在使用 .NET 框架解决方案而不是 .NET 核心,因为我正在处理由微软引起的 NuGet 包管理器错误。我还在 .NET 框架中使用其他 NuGet 包,例如 Discord.NET。

所以我可以在 NuGet 包管理器中找到 2 个 Whatsapp API。 API 的第一个版本在 v1.2.2 上,另一个在 v15.4.29 上。

此外,我想添加用于注册的代码。

bool registrationSucces = WhatsRegisterV2.RequestCode(number, out password, out error);

要完全重现错误: https://pastebin.com/EJhjALwz 包含前面提到的两个可用的 nuget 包(v1.2.2 或 v15.4.29 上的那个)

我期待任何对 API 或编码有更多了解的人可以帮助我解决这个挫折。

【问题讨论】:

  • 如果您能提供minimal reproducible example 并提及您正在使用的显式 软件包版本号,那就太好了。
  • 我编辑了原始帖子,以便包含更好和更多的信息。感谢您就如何在此论坛上正确发布编码问题提供反馈。
  • 您至少应该提供有关您正在使用的 Library/NuGet 包的信息。 WhatsRegisterV2 类匹配例如到github.com/mgp25/Chat-API-NET,它从 2006 年开始就已经过时了(在 WA 的 E2EE 之前,所以这肯定行不通)
  • @Lion 我确实指定了我尝试过的 nuget 包的版本。两者都返回了相同的错误。另外:如果我的 API 真的过时了,它的原因是什么?我无法在 .Net 控制台应用程序中进一步更新 NuGet 包
  • @jellekeulemans 请注意,不是每个人都能看到 pastebin

标签: c# nuget console-application whatsapp whatsapi


【解决方案1】:

下载github这个项目 试试这个配置:

    using System;
    using System.Globalization;

    namespace WhatsAppApi.Settings
       {
               /// <summary>
               /// Holds constant information used to connect to whatsapp 
             server
                 /// </summary>
                  public class WhatsConstants
                   {
                    #region ServerConstants

        /// <summary>
        /// The whatsapp host
        /// </summary>
        public const string WhatsAppHost = "c3.whatsapp.net";

        /// <summary>
        /// The whatsapp XMPP realm
        /// </summary>
        public const string WhatsAppRealm = "s.whatsapp.net";

        /// <summary>
        /// The whatsapp server
        /// </summary>
        public const string WhatsAppServer = "s.whatsapp.net";

        /// <summary>
        /// The whatsapp group chat server
        /// </summary>
        public const string WhatsGroupChat = "g.us";

        /// <summary>
        /// The whatsapp version the client complies to
        /// </summary>
        //public const string WhatsAppVer = "2.13.21";
        //public const string WhatsAppVer = "2.12.440";
        //public const string WhatsAppVer = "2.12.556";
        public const string WhatsAppVer = "2.19.368";

        /// <summary>
        /// The port that needs to be connected to
        /// </summary>
        public const int WhatsPort = 443;

        /// <summary>
        /// iPhone device
        /// </summary>
        //  public const string Device = "S40";
        public const string Device = "Android";

        /// <summary>
        /// manufacturer
        /// </summary>
        public const string Manufacturer = "HTC";

        /// <summary>
        /// OS Version
        /// </summary>
        public const string OS_Version = "4.3";

        /// <summary>
        /// The useragent used for http requests
        /// </summary>
        //public const string UserAgent = "WhatsApp/2.13.21 S40Version/14.26 Device/Nokia302";
        //public const string UserAgent = "WhatsApp/2.12.440 Android/4.3 Device/Xiaomi-HM_1SW";
        public const string UserAgent = "WhatsApp/2.19.368 Android/4.3 Device/endeavoru-IMM76D";


        #endregion

        #region ParserConstants
        /// <summary>
        /// The number style used
        /// </summary>
        public static NumberStyles WhatsAppNumberStyle = (NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign);

        /// <summary>
        /// Unix epoch DateTime
        /// </summary>
        public static DateTime UnixEpoch = new DateTime(0x7b2, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
        #endregion
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-22
    • 2022-12-23
    • 2020-06-20
    • 1970-01-01
    • 2022-09-28
    • 2022-10-15
    • 2022-06-22
    • 2022-12-19
    相关资源
    最近更新 更多