Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Whatsapp API Error!

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.
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?
[Image: UylCjc.png]
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
probably missing reference error
[Image: bitcoin.png] Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
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);
<Disease />
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'--
(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.
<Disease />


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by kookurSep 15, 2018 09:23 AM 13 488 Sep 15, 2018 09:23 AM
Last Post: kookur
[Java] by GlushkoJun 13, 2018 11:13 PM 3 642 Jun 13, 2018 11:13 PM
Last Post: hostov
[C#] by GladikSep 17, 2017 01:54 AM 0 169 Sep 17, 2017 01:54 AM
Last Post: Gladik