Hi Kyle. I got the bearer token via below code.
$key = urlencode(CONSUMER_KEY);
$secret = urlencode(CONSUMER_SECRET);
$basic_credentials = base64_encode($key . ':' . $secret);
$ch = curl_init('https://api.twitter.com/oauth2/token');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Basic '.$basic_credentials, 'Content- Type: application/x-www-form-urlencoded;charset=UTF-8'));
curl_setopt($ch, CURLOPT_POSTFIELDS, 'grant_type=client_credentials');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$token = json_decode(curl_exec($ch));
curl_close($ch);
if (isset($token->token_type) && $token->token_type == 'bearer') {
$bearer_access_token = $token->access_token;
}
Then I registered webhook using the bearer token. It returned below error.
{"errors":[{"code":89,"message":"Invalid or expired token."}]}
In the docs I haven’t found how to pass the user context. Could you please explain more about “passing a user context as well (with a bearer token)”?
Thank you!