GET /api/v1
Parameter | Type | Description |
---|---|---|
requestSession |
string |
Required. Your Session key |
action |
actionType |
Required. Your Action type |
- exampleHTTPRequest
- exampleHTTPLogin
- exampleHTTPRegister
public static void SendRegisterRequest(string username, string password, string email, string sessionToken)
{
var client = new HttpClient();
var values = new Dictionary<string, string>
{
{ "requestSession", sessionToken },
{ "action", "exampleHTTPRegister" },
{ "username", username },
{ "password", password },
{ "email", email }
};
var content = new FormUrlEncodedContent(values);
var response = client.PostAsync("https://v-devs.online/demoHTTPLogin/api/v1/", content).Result;
var responseString = response.Content.ReadAsStringAsync().Result;
dynamic responseJson = JsonConvert.DeserializeObject(responseString);
Console.WriteLine(responseJson);
}
Here is an example how to generate session token using C#
public static void CreateSession()
{
server = "";
database = "";
user = "";
password = "";
port = "3306";
sslM = "none";
connectionString = String.Format("server={0};port={1};user id={2}; password={3}; database={4};", server, port, user, password, database, sslM);
conString = connectionString;
connection = new MySqlConnection(conString);
try
{
connection.Open(); // Open connection
connected = true;
var bytes = new byte[32]; // Create new byte
using (var rng = RandomNumberGenerator.Create())
{
rng.GetBytes(bytes);
session =Convert.ToBase64String(bytes).Substring(0, 32); // Assign the generated session
}
MySqlCommand createSession = new MySqlCommand("INSERT INTO example_sessions(sessionHash) VALUES(@session)", connection); // Prepare the SQL Statement
createSession.Parameters.AddWithValue("@session", session); // Add session parameter
createSession.ExecuteScalar(); // Execute command
}
catch (MySqlException error)
{
Console.WriteLine("There was an error while trying to connect the database ! \r\n Message: " + error.Message);
}
}
Here is an example how to destroy session using PHP
$destroySession= $conn->prepare("DELETE FROM example_sessions WHERE sessionHash = ?");
$destroySession->bind_param("s",$_POST['requestSession']);
$destroySession->execute();
⚠ If you are going to use the sample C# code make sure it is obfuscated otherwise you risk exposing sensitive data from the code
- .NET >= 3.5 [ ! For the demo application !]
- PHP <=7.4