I’m trying to post to https://api.twitter.com/oauth2/token to get the application bearer token and I’m getting “Sorry, that page doesn’t exist!”. Is it not working or something I’m doing? This code worked yesterday, btw.
$bearer = $cfg['twitter']['consumer_key'] . ':' . $cfg['twitter']['consumer_secret'];
$bearer = base64_encode($bearer);
$ci = curl_init();
/* Curl settings */
curl_setopt($ci, CURLOPT_USERAGENT, "My User Agent 1.0");
curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ci, CURLOPT_TIMEOUT, 30);
curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ci, CURLOPT_HTTPHEADER, array('Authorization: Basic ' . $bearer));
curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ci, CURLOPT_HEADER, FALSE);
$postfields = array("grant_type"=>"client_credentials");
curl_setopt($ci, CURLOPT_POST, TRUE);
if (!empty($postfields)) {
curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
}
curl_setopt($ci, CURLOPT_URL, "https://api.twitter.com/oauth2/token");
$response = curl_exec($ci);
$http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
$http_info = curl_getinfo($ci);
curl_close ($ci);
echo $response;