FiWare WP-OAuth用户认证PHP CURL


FiWare WP-OAuth user authentication PHP CURL

我正在使用FiWare.org的KeyRock。以前一切似乎都能找到工作,但现在用户授权后的其余服务器向我发送以下响应。我看了看服务器响应,它似乎是一个NULL/空响应。但是在NodeJS上,请求被无缝地处理。我正在使用wp-oauth插件,并已将其修改为与FiWare一起工作。我通过PHP CURL发送这个请求。

    {
    "error": {
        "message": "Expecting to find application/json in Content-Type header - the server could not comply with the request since it is either malformed or otherwise incorrect. The client is assumed to be in error.",
        "code": 400,
        "title": "Bad Request"
    }
   }

下面是我使用的CURL请求:

$url = URL_TOKEN . $url_params;
$curl = curl_init();   
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); 
curl_setopt($curl, CURLOPT_USERPWD, CLIENT_ID . ":" . CLIENT_SECRET);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, (get_option('wpoa_http_util_verify_ssl') == 1 ? 1 : 0));
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, (get_option('wpoa_http_util_verify_ssl') == 1 ? 2 : 0));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);

您是否尝试在Content-Type header中添加application/json ?

BR