Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can schedule tweet #1224

Closed
uzanzi opened this issue Feb 28, 2024 · 1 comment
Closed

Can schedule tweet #1224

uzanzi opened this issue Feb 28, 2024 · 1 comment
Labels

Comments

@uzanzi
Copy link

uzanzi commented Feb 28, 2024

Is it possible to schedule a post on Twitter ?

My code :

if ($new_status == 'publish') {
        $parameters = [
            'text' => $tweet,
        ];
        // Publie le tweet
        $status = $connection->post('tweets', $parameters);
        }else if ($new_status == 'future') {
            $timeToPublished = "";
            $year2Pub = $_POST['aa'];
            $month2Pub = $_POST['mm'];
            $day2Pub = $_POST['jj'];
            $hour2Pub = $_POST['hh'];
            $minute2Pub = $_POST['mn'];
            $sec2Pub = $_POST['ss'];

            $timeZone = 'Europe/Paris';  // +2 hours
            $dateSrc = '' . $year2Pub . '-' . $month2Pub . '-' . $day2Pub . ' ' . $hour2Pub . ':' . $minute2Pub . ':' . $sec2Pub . '';
            $dateTime = new DateTime($dateSrc);
            $dateTime->setTimeZone(new DateTimeZone($timeZone));
            $timeToPublished = $dateTime->format('Y-m-d\TH:i:sO');

            $parameters = [
                'text' => $tweet,
                'scheduled' => $timeToPublished
            ];

            // Programmer le tweet
            $status = $connection->post('tweets', $parameters);
        }

This code didn't work for me.

Thank you for your response.

@uzanzi uzanzi added the Triage label Feb 28, 2024
@abraham
Copy link
Owner

abraham commented Mar 3, 2024

Twitter API doesn't support it https://developer.twitter.com/en/docs/twitter-api/tweets/manage-tweets/api-reference/post-tweets

@abraham abraham closed this as completed Mar 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants