How to post with Request Payload

Asked

Viewed 1,927 times

0

I have the following code:

$url = 'https://www.habbo.com.br';
$email = '[email protected]';
$pass = '123456';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_COOKIESESSION, false);
curl_setopt($ch, CURLOPT_COOKIEJAR, getcwd().'/login.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, getcwd().'/login.txt');
curl_setopt($ch, CURLOPT_REFERER, 'https://google.com');
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'email='.$email.'&password='$pass.);

When I submit the login form on the website https://www.habbo.com.br/ using the Google Chrome Network function (in Devtools) in the sent header, it shows Request Payload. How do I submit a form using this Request Payload?

1 answer

2


You need to send a JSON to Habbo’s website, because that’s what it expects of you:

$data = json_encode(['email'=>$email, 'password'=>$pass]);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

And then you have to send a header stating this:

curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER,
               array('Content-Type:application/json',
                      'Content-Length: ' . strlen($data))
               );

See examples here:

Browser other questions tagged

You are not signed in. Login or sign up in order to post.