指定した複数の文字列を含まない1行を検索する 正規表現。
指定した複数の文字列を含まない1行を検索する
^(?!.*(文字列|文字列)).+$
文字列を|(パイプ)で繋げることで、複数の文字列を除外することが出来ます。
twitter v2 tweet
通常のツイート
参照サイト
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',
),
)
やっとここまできた!
twitter api v2 post で 自分の投稿へのリプライにに返信したい。けどリフレッシュトークンまで
- 最初はplainで行った方が良い
- どうしても上手くいかない場合
developerサイトで
アプリの種類をかえてみる。
POST /2/tweets
JSON body parameters
Parameter
|
Description
|
response_type
|
You will need to specify that this is a code with the word “code”.
|
client_id
|
Can be found in the developer portal under the header "Client ID".
|
redirect_uri
|
Your callback URL. This value must correspond to one of the Callback URLs defined in your App’s settings. For OAuth 2.0, you will need to have exact match validation for your callback URL.
|
state
|
A random string you provide to verify against CSRF attacks. The length of this string can be up to 500 characters.
|
code_challenge
|
A PKCE parameter, a random secret for each request you make.
|
code_challenge_method
|
Specifies the method you are using to make a request (S256 OR plain).
|
アクセストークンの更新
php で phantomjs検討、duskをつかってスクレイピングする。
composerでtinkerをいれたい
■
php8.1
composer self-update時にエラー
The openssl extension is required for SSL/TLS protection but is not available. If you can not enable the openssl extension, you can disable this error, at your own risk, by setting the 'disable-tls' option to true .
php.iniの修正が必要
https://digirakuda.org/blog/2018/06/04/post-251/