error 405 Method Not Allowed

0

I'm trying to log in and return the panel to a web site pore me and returned a 405 Method Not Allowed error how can I resolve this?

<?php



$email = '   ';

$senha = '  ';


$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://host.com/login');

curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); 

curl_setopt ($ch, CURLOPT_POST, 1);

curl_setopt ($ch, CURLOPT_POSTFIELDS, '_username=$email&_password=$senha');

curl_setopt($ch, CURLOPT_COOKIESESSION, true);

$store = curl_exec ($ch);

curl_setopt($ch, CURLOPT_URL, 'https://host.com/dashboard/');

curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); 

$prok =curl_exec($ch);

curl_close ($ch);

echo $prok;


?>
    
asked by anonymous 09.07.2017 / 17:01

1 answer

4

You can not figure out the problem, this is the server you are trying to access that is issuing a block, for example when a server responds with:

  

405 Method Not Allowed

It means that it does not allow the method you tried to use, if you tried POST it might not allow POST , or maybe curl is trying to send POST but the "verb" is marked as GET (if it's a bug in your PHP version, which I think is unlikely), then try to force this:

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');

For the rest it is only possible to determine the problem knowing which page you are trying to access.

[Edit]

Change the URL of the first CURL to (note that the correct is /login_check and not /login ):

curl_setopt($ch, CURLOPT_URL, 'http://minhaconta.payleven.com.br/login_check');

And correct the CURLOPT_POSTFIELDS , need to concatenate and encode the values (single quotation marks do not allow to receive the values of the variables):

curl_setopt ($ch, CURLOPT_POSTFIELDS, '_username=' . urlencode($email) . '&_password=' . urlencode($senha));

And due to server redirection I recommend adding this:

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

Add in both curls.

    
09.07.2017 / 17:09