I am trying to obtain an API token from Twitter using Unirest.io PHP. My code is as follows:
[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")
);
What I get from Twitter is:
{
errors: [
{
code: 170,
label: "forbidden_missing_parameter",
message: "Missing required parameter: grant_type"
}
]
}
As I understand it, it requires the "body" of the request to contain "grant_type":"client_credentials", which I thought is included in the unirest request above, but apparently this is not the case. Any help or comments?