通常のツイート
参照サイト
https://zenn.dev/snowcait/articles/32c351553ae67c
エラー文章
Authenticating with OAuth 2.0 Application-Only is forbidden for this endpoint. Supported authentication types are [OAuth 1.0a User Context, OAuth 2.0 User Context]
参照
-https://ohwhsmm7.blog.fc2.com/blog-entry-602.html
>>
Authentication and rate limitsの対応しているエンドポイントは
OAuth 1.0a User Context
OAuth 2.0 Authorization Code with PKCE
でした
OAuth 2.0 Bearer Token
が無い
users.read も必要
とのこと
scopeに追加
結果
array (
'errors' =>
array (
0 =>
array (
'parameters' =>
array (
),
'message' => 'Request body is not valid JSON.',
),
),
'title' => 'Invalid Request',
'detail' => 'One or more parameters to your request was invalid.',
'type' => 'https://api.twitter.com/2/problems/invalid-request',
)
json_encode
で変換して、再度ツイート
成功!
$ php post.php
array (
'data' =>
array (
'id' => '1511603460013445120',
'text' => 'text',
),
)
やっとここまできた!