Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Text to X (twitter) (with oauth) 2025-06
- //MH+ presents, visit my blog => https://sl-memo.blogspot.com/
- //X (twitter) oauth ライブラリー GitHub - abraham/twitteroauth を使用
- // https://github.com/abraham/twitteroauth
- require __DIR__ . '/twitter_oauth/autoload.php';
- //ca-bundle GitHub - composer/ca-bundle も必要
- // https://github.com/composer/ca-bundle
- require __DIR__ . '/ca-bundle/src/CaBundle.php';
- // TwitterOAuthクラスをインポート
- use Abraham\TwitterOAuth\TwitterOAuth;
- $connect = new TwitterOAuth(
- '*************************' // API Keyをセット
- ,'**************************************************' // API Secretをセット
- ,'**************************************************' // Access Tokenをセット
- ,'*********************************************' // Access Token Secretをセット
- );
- $connect->setApiVersion('2');//V2指定
- $message = "テストデータ URLテスト #TagTEST \n https://www.yahoo.com/";
- $result = $connect->post(
- 'tweets'
- ,['text' => $message]
- ,['jsonPayload'=>true]
- );
- $httpCode = $connect->getLastHttpCode();
- $last = $connect->getLastXHeaders();
- if(($httpCode >= 200) && ($httpCode <= 299)){
- //正常
- } else {
- //エラー
- print_r($result);
- print_r($last);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement