Error 405 Method Not Allowed

Asked

Viewed 1,550 times

0

I am trying to log in and return on the screen the panel of a site pore me and returned an error 405 Method Not Allowed how can I fix 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;


?>

1 answer

3


There is no way to deduce the problem, this is the server you are trying to access that is emitting a lock, for example when a server responds with:

405 Method Not Allowed

He means he doesn’t allow the method you tried to use if you tried POST maybe he won’t allow POST, or maybe the curl is trying to send POST but the "verb" will be marked as GET (if it is a bug in your version of PHP, which I find unlikely), then try to force this set:

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

Otherwise it is only possible to determine the problem knowing which page is trying to access.


[Editing]

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

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

And fix the CURLOPT_POSTFIELDS, need to concatenate and encode the values (single quotes do not allow receiving the values of the variables):

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

And due to server redirection I recommend you add this:

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

Add in both Urls.

  • I am trying to access the https://minhaconta.payleven.com.br/login page to create my custom management panel

  • The whole message Oops! An Error Occurred The server returned to "405 Method Not Allowed". Something is Broken. Please Let us know what you Were Doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused

  • Now the code of errp returned is: 301 Moved Permanently Nginx

Browser other questions tagged

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