How to send post with Request Payload

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 https://www.habbo.com.br/ site using the Chrome Network (DevTools) function in the header sent, it shows Request Payload . How do I submit a form using this Request Payload ?

    
asked by anonymous 05.12.2016 / 07:02

1 answer

2

You need to send a JSON to the Habbo site, because that's what he expects of you:

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

And then you have to send a header saying this:

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

See examples here:

05.12.2016 / 10:32