Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Will php-simple-proxy accept POST with username pasword parameters? #29

Open
Alphagrey opened this issue Sep 25, 2015 · 0 comments
Open

Comments

@Alphagrey
Copy link

My POST request gives the following error:
HTTP Error 405.0 - Method Not Allowed
The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used. What is wrong with my format?

$.ajax({
url: 'ba-simple-proxy.php',
type: 'POST',
data: { url: 'https://api.someapiprovider/oauth2/access_token?grant_type=refresh_token&refresh_token=VdsltyABCD3Ze_zQz33yp2_PTeT12345' },
dataType: "json",
success: function (result) {
switch (result) {
case true:
alert("Success:" + result);
break;
default:
resultDiv.html(result);
}
},
error: function (xhr, ajaxOptions, thrownError) {
alert("Error Status:" + xhr.status);
alert(thrownError);
}
});

And inside ba-simple-proxy.php I added the following:
$ch = curl_init( $url );

if ( strtolower($_SERVER['REQUEST_METHOD']) == 'post' ) {
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query($_POST));
curl_setopt( $ch, CURLOPT_USERPWD, "yergWXMTk:HgGq8dCVBL5YFYwx")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant