Any issue about Cyclos 4 scripting and Webservices
Moderators: alexandre , hugo , rmvanarkel
canoodle
Posts: 12 Joined: Sun Feb 04, 2018 8:33 pm
Post
by canoodle » Thu May 14, 2020 11:26 am
Hello,
thanks for cyclos
if one would like to write completely customized / own login page for cyclos in php:
https://demo.cyclos.org/api
the login form could look like this:
but: what parameters inputs are needed?
also: where to send the request? action="
http://request/where/shall/u/go "
the login html could be like this:
Code: Select all
<form class="form-signin" action="http://request/where/shall/u/go">
<input name="action" value="login" hidden="">
<div class="table">
<div class="column100">
<div class="line">
<img class="profilepicture" src="" alt="profile Picture">
</div>
<div class="line">
<div class="prop">
usr:
</div>
<div class="value">
<input id="who_username" name="username" type="username" placeholder="username" value="">
</div>
</div>
<div class="line">
<div class="prop">
pwd:
</div>
<div class="value">
<input id="who_password" name="password" type="password" placeholder="passwort" value="">
</div>
</div>
<div class="line">
<div class="prop">
<div id="status_login" class="status_error">status:</div>
</div>
<div class="value">
<div id="status" class="status">status</div>
</div>
</div>
</div>
</div>
<div class="column100">
<input type="submit" name="login" value="login" class="button" style="width: 100%; height: 40px;">
</div>
</form>
or: maybe someone can to an example?
jakob.schumann
Posts: 63 Joined: Thu Apr 23, 2020 5:37 pm
Post
by jakob.schumann » Wed Jun 10, 2020 3:44 am
Hello!
To receive a session token that can be used to redirect the user to cyclos or use as an auth mechanism via the API you can POST to /sessions and give the following as body parameters in JSON:
user - login name/email/userid
password
remoteAddress - the IP the user used to access your PHP script, for blocking not your server but the user on failed tries
See
https://demo.cyclos.org/api/#operations ... -loginUser for details.
Best regards,
JS
nehakakar
Posts: 3 Joined: Tue Jul 04, 2023 9:35 am
Contact:
Post
by nehakakar » Wed Aug 09, 2023 10:43 am
It an Example how you can create a custom login form for the Cyclos API using PHP.
Code: Select all
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Set the API endpoint URL
$apiUrl = "https://demo.cyclos.org/api/access-point";
// Prepare data for the login request
$postData = [
"action" => "login",
"username" => $_POST["username"],
"password" => $_POST["password"]
];
// Initialize cURL session
$ch = curl_init($apiUrl);
// Set cURL options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
// Execute the cURL request
$response = curl_exec($ch);
// Close cURL session
curl_close($ch);
// Process the API response
$responseData = json_decode($response, true);
if ($responseData["success"]) {
// Successful login, you can perform additional actions here
echo "Login successful!";
} else {
// Login failed, display an error message
echo "Login failed: " . $responseData["message"];
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Cyclos Login</title>
</head>
<body>
<form class="form-signin" method="post">
<div class="table">
<div class="column100">
<div class="line">
<img class="profilepicture" src="" alt="profile Picture">
</div>
<div class="line">
<div class="prop">
usr:
</div>
<div class="value">
<input id="who_username" name="username" type="text" placeholder="username" value="">
</div>
</div>
<div class="line">
<div class="prop">
pwd:
</div>
<div class="value">
<input id="who_password" name="password" type="password" placeholder="password" value="">
</div>
</div>
<div class="line">
<div class="prop">
<div id="status_login" class="status_error">status:</div>
</div>
<div class="value">
<div id="status" class="status">status</div>
</div>
</div>
</div>
</div>
<div class="column100">
<input type="submit" name="login" value="Login" class="button" style="width: 100%; height: 40px;">
</div>
</form>
</body>
</html>
This example uses the cURL library to send a POST request to the Cyclos API's login endpoint and processes the API response accordingly.
Make sure to replace the actual API endpoint URL. For API reference visit
API .