- using System;
- using System.IO;
- using System.Net.Sockets;
- using System.Text;
- class YeastarGT400Client
- {
- private const string Host = "192.168.5.150"; // Replace with your GT400's IP address
- private const int Port = 5038; // Default port for Yeastar API
- private const string Username = "administrator"; // Replace with your API username
- private const string Password = "P@ssw0rd"; // Replace with your API password
- static void Main()
- {
- try
- {
- using (NetworkStream stream = client.GetStream())
- {
- // Read the initial response from the server
- string response = reader.ReadLine();
- Console.WriteLine("Server: " + response);
- // Send login command
- writer.WriteLine($"Action: Login\r\nUsername: {Username}\r\nSecret: {Password}\r\n\r\n");
- // Read login response
- response = reader.ReadLine();
- Console.WriteLine("Server: " + response);
- // Send SMS command
- string smsCommand = "Action: smscommand\r\ncommand: gsm send sms 1 1234567890 \"Hello, this is a test message.\"\r\n\r\n";
- writer.WriteLine(smsCommand);
- // Read SMS send response
- response = reader.ReadLine();
- Console.WriteLine("Server: " + response);
- // Logoff
- writer.WriteLine("Action: Logoff\r\n\r\n");
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine("Error: " + ex.Message);
- }
- }
- }
Recent Pastes