wp_remote_get passing authentication, but then failing in body
-
Hello
I’m attempting to use wp_remote_get for the first time
Really, this is my first major api job, so I’m just trying to get a grasp of deeper parts of API connections, PLUS wp_remote_getThe code I’m using to attempt to attempt to the api is as follows:
<?php $url = "url"; $username = "username"; $password = "password"; $headers = array( "Authorization" => "Basic " . base64_encode( "$username:$password" ), "sslverify" => false ); $response = wp_remote_get($url, $headers); if (is_wp_error($response)){ echo $response->get_error_message(); }else{ print_r($response); } ?>
I had originally tried without “sslverify”, but it would fail authentication.
Adding in sslverify goes to the else part of the function, but returns the following:
Array ( [headers] => Array ( [cache-control] => no-cache [pragma] => no-cache [content-type] => application/json; charset=utf-8 [expires] => -1 [server] => Microsoft-IIS/7.5 [www-authenticate] => Basic [x-aspnet-version] => 4.0.30319 [x-powered-by] => ASP.NET [date] => Mon, 30 Nov 2015 22:40:16 GMT [connection] => close [content-length] => 61 ) [body] => {"Message":"Authorization has been denied for this request."} [response] => Array ( [code] => 401 [message] => Unauthorized ) [cookies] => Array ( ) [filename] => )
It seems like authentication has failed.. but hasn't it already passed? Am I missing params somewhere in the original call?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘wp_remote_get passing authentication, but then failing in body’ is closed to new replies.