Skip to content

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

@Alphagrey

Description

@Alphagrey

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")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions