我正在尝试使用 Unirest.io PHP 从 Twitter 获取 API 令牌。我的代码如下:
[in PHP]
$response = Unirest::post("https://api.twitter.com//oauth2/token",
array(
"Authorization" => "Basic [AUTH_KEY]",
"Content-Type" => "application/x-www-form-urlencoded;charset=UTF-8"
),
array("grant_type" => "client_credentials")
);
我从 Twitter 得到的是:
{
errors: [
{
code: 170,
label: "forbidden_missing_parameter",
message: "Missing required parameter: grant_type"
}
]
}
据我了解,它要求请求的“正文”包含“grant_type”:“client_credentials”,我认为它包含在上面的唯一请求中,但显然情况并非如此。任何帮助或意见?