php curl send post command to MW - a future wordpress plugin ( if it will work :) )

nemesis82

Active Member
Hy guys,
i am trying to develop an open source plugin for wordpress to login into mailwizz. When it will work i release this plugin totally free but i need some support :)

Explanation :
wordpress hosted on "www.example.com"
mw hosted on "www.mymailwizz.com"

2 different domains

mw side i dont want touch nothing (csrf must also be enabled)

in my dev lab , i pass username, password and got csrf token per session but in my output i get this result ( see image attached ) .
In address bar i keep my local address ( wordpress ) and not the mw site and all link redirect to my local address ( eg. http://10.15.10.2/customer/dashboard/index )

any suggestion ?

this is my code

PHP:
$ch = curl_init("https://mymailwizz.com/customer/guest/index/login.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
$response = curl_exec($ch);

$dom = new DomDocument;
$dom->loadHTML($response);
$tags = $dom->getElementsByTagName('input');
for($i = 0; $i < $tags->length; $i++) {
        $grab = $tags->item($i);
        if($grab->getAttribute('name') === 'csrf_token') {
                $token =  $grab->getAttribute('value');
}
}
//echo $token; /debug

$data = array(
        "CustomerLogin[email]" => "myusername",
        "CustomerLogin[password]" => "mypassword",
        "csrf_token" => $token,
);

curl_setopt($ch, CURLOPT_URL, "https://mymailwizz.com/customer/guest");
curl_setopt($ch, CURLOPT_POST, true );
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$response = curl_exec($ch);
echo $response;



1627504021388.png
 
Back
Top