I created a simple script to check if it is possible to log in as admin.
(我创建了一个简单的脚本来检查是否可以以管理员身份登录。)
<?php
$data = array(
"log" => "admin",
"pwd" => "admin"
);
$string = http_build_query($data);
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, "http://www.tech-world.ovh/wp-login.php");
curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($curl, CURLOPT_FOLLOWLOCATION, true); // Allow redirections
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, true); //Allow us to store request response in some variable
curl_setopt ($curl, CURLOPT_COOKIEJAR, 'cookie.txt'); //Cookie
curl_setopt ($curl, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt ($curl, CURLOPT_REFERER, "http://www.tech-world.ovh/wp-login.php");
curl_setopt ($curl, CURLOPT_POSTFIELDS, $string);
curl_setopt ($curl, CURLOPT_POST, 1);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
$login_successful = strpos($response, "Kokpit") !== FALSE;
if($login_successful){
echo "Success";
}
else{
echo "Login Error";
}
Okay, and it works.
(好的,它有效。)
But.. I'd like to use the WP REST API to build cookie-base auth, so I have read the documentation Click but I still don't understand how to do it. (但是..我想使用WP REST API来构建基于cookie的身份验证,因此我已经阅读了Click的文档,但是我仍然不知道该怎么做。)
Which url shoud I use? (我应该使用哪个网址?)
How to send a POST request to REST API? (如何发送POST请求到REST API?)
How to check if the login data are correct? (如何查看登录数据是否正确?)
ask by Incybro Shostak translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…