tôi sử dụng đoạn mã sau để có mã thông báo bearer:Twitter 1.1 OAuth authenticity_token_error (99)
$token = base64_encode($client_id.':'.$client_sec);
$data = array ('grant_type' => 'client_credentials');
$data = http_build_query($data);
$header = array(
'Authorization: Basic '.$token,
'Content-type: application/x-www-form-urlencoded;charset=UTF-8',
'Content-Length: ' . strlen($data)
);
$options = array(
CURLOPT_HTTPHEADER => $header,
CURLOPT_HEADER => false,
CURLOPT_URL => 'https://api.twitter.com/oauth2/token',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => $data
);
$ch = curl_init();
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
curl_close($ch);
print_r($result);
exit;
Nhưng đầu ra tất cả các thời gian:
{"errors":[{"label":"authenticity_token_error","code":99,"message":"Unable to verify your credentials"}]}
Những gì tôi làm sai rồi?
Vâng, rất có thể thông tin đăng nhập không đúng và do đó chúng không thể được xác thực? – hakre
Vâng, cảm ơn bạn. –