我正在向我们网络上的另一个wordpress网站发出请求,如下所示。
//Send the request to update the submission post
$response = wp_remote_request( $this->urls->assign_url, array(
'headers' => array(
'Content-Type' => 'application/json; charset=utf-8',
'Authentication' => 'Basic '.base64_encode('somename:somepassword')
),
'body' => json_encode($array),
'method' => 'POST',
'data_format' => 'body'
)
);
我一直想回来的是:
body: "{"code":"rest_not_logged_in","message":"You are not currently logged in.","data":{"status":401}}"
自从我更新了远程wordpress版本以来,我才刚刚开始获取此信息。在此之前一切正常。
任何想法。
我相信,为了对您想要的方式进行身份验证,您需要使用插件-内置身份验证方法不适用于异地请求,因为它基于cookie。
https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/#authentication-plugins