Hack Forums
[.NET] Whatsapp API Error! - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Whatsapp API Error! (/showthread.php?tid=5926690)



Whatsapp API Error! - HardStoN - Jan 6, 2019

hey guys i tried to make whatsapp sender using c# this is my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Net.Sockets;
using System.Net.WebSockets;
using WhatsAppApi.Register;
using WhatsAppApi.Account;
using WhatsAppApi;
using WhatsAppApi.Response;

namespace CommunicationSourcesWithThirdPartyApps
{
class Program
{
public static string name;
public static string message;
public static string password;
public static string to;
public static string phoneNumber;


static void Main(string[] args)
{
WhatsApp wa = new WhatsApp(phoneNumber, password, name, true);

Console.WriteLine("Enter your phone number: ");
phoneNumber = Console.ReadLine();

Console.WriteLine("Enter your name: ");
name = Console.ReadLine();

Console.WriteLine("Enter your message: ");
message = Console.ReadLine();

Console.WriteLine("Where to send the message: ");
to = Console.ReadLine();

password = WhatsRegisterV2.GetToken(phoneNumber);

wa.OnConnectSuccess += () =>
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Connected...");
wa.OnLoginSuccess += (phone, data) =>
{
Console.WriteLine("Login success!");
wa.SendMessage(to, message);
Console.WriteLine("Message Sent!");
};

wa.OnLoginFailed += (data) =>
{
Console.WriteLine("Login failed!");
};

wa.Login();
};

wa.OnConnectFailed += (ex) =>
{
Console.WriteLine("Connection Failed!");
};

wa.Connect();

Console.ReadLine();

}
}
}

and im getting error at -wa.Login();- Object reference not set to an instance of an object.


RE: Whatsapp API Error! - I ɴ ᴄ ʀ ᴇ ᴅ ɪ ʙ ʟ E - Jan 6, 2019

I'm not a coder. but I'm sure there's a few similar programmes already existed and they are open-source.
are you coding from scratch?


RE: Whatsapp API Error! - HardStoN - Jan 6, 2019

I'm not a coder. but I'm sure there's a few similar programmes already existed and they are open-source.
are you coding from scratch?
yes


RE: Whatsapp API Error! - HFDone - Jan 6, 2019

probably missing reference error


RE: Whatsapp API Error! - Disease - Jan 6, 2019

I'm not familiar with this API. But looking at this logically, my first thought is your instantiation of the API. You declare wa, and instantiate it, using information you haven't gathered yet from the user.

Code
// phoneNumber, password, and name haven't been set yet, only declared...
//WhatsApp wa = new WhatsApp(phoneNumber, password, name, true);

Console.WriteLine("Enter your phone number: ");
phoneNumber = Console.ReadLine();

Console.WriteLine("Enter your name: ");
name = Console.ReadLine();

Console.WriteLine("Enter your message: ");
message = Console.ReadLine();

Console.WriteLine("Where to send the message: ");
to = Console.ReadLine();

password = WhatsRegisterV2.GetToken(phoneNumber);

// At this point the values have been declared.
WhatsApp wa = new WhatsApp(phoneNumber, password, name, true);



RE: Whatsapp API Error! - HardStoN - Jan 6, 2019

I'm not familiar with this API.  But looking at this logically, my first thought is your instantiation of the API.  You declare wa, and instantiate it, using information you haven't gathered yet from the user.

Code
// phoneNumber, password, and name haven't been set yet, only declared...
//WhatsApp wa = new WhatsApp(phoneNumber, password, name, true);

Console.WriteLine("Enter your phone number: ");
phoneNumber = Console.ReadLine();

Console.WriteLine("Enter your name: ");
name = Console.ReadLine();

Console.WriteLine("Enter your message: ");
message = Console.ReadLine();

Console.WriteLine("Where to send the message: ");
to = Console.ReadLine();

password = WhatsRegisterV2.GetToken(phoneNumber);

// At this point the values have been declared.
WhatsApp wa = new WhatsApp(phoneNumber, password, name, true);

Lol now im getting the eror at wa.Login(); -System.Exception: 'Auth response error'--


RE: Whatsapp API Error! - Disease - Jan 6, 2019

(Jan 6, 2019 12:21 PM)HardStoN Wrote:  I'm not familiar with this API.  But looking at this logically, my first thought is your instantiation of the API.  You declare wa, and instantiate it, using information you haven't gathered yet from the user.

Code
// phoneNumber, password, and name haven't been set yet, only declared...
//WhatsApp wa = new WhatsApp(phoneNumber, password, name, true);

Console.WriteLine("Enter your phone number: ");
phoneNumber = Console.ReadLine();

Console.WriteLine("Enter your name: ");
name = Console.ReadLine();

Console.WriteLine("Enter your message: ");
message = Console.ReadLine();

Console.WriteLine("Where to send the message: ");
to = Console.ReadLine();

password = WhatsRegisterV2.GetToken(phoneNumber);

// At this point the values have been declared.
WhatsApp wa = new WhatsApp(phoneNumber, password, name, true);

Lol now im getting the eror at wa.Login(); -System.Exception: 'Auth response error'--

Going to exalt my ignorance here, but it's the only thing coming to mind: do you even have access to the WhatsApp API? I don't think the API is public yet... I know Twilio offers a fairly public abstraction of the WhatsApp API though.