-1

Does anyone have experience with the Twitter API? I'm developing my site that can tweet status to twitter timeline from my site. Since now, a new status will post to twitter timeline after clicked on button Tweet.

However, I want to set datetime to post status to Twitter timeline. For example, I set datetime to post at 9AM and I click button at 8AM; so at 9AM, new status will be post in twitter timeline. Is that possible?

My code

This code will post new status when click on button Tweet:

<?php

session_start();
$message = "I want to set datetime to tweet new status";
$access_token = $_SESSION['access_token'];
$connection = new TwitterOAuth(YOUR_CONSUMER_KEY, YOUR_CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);
$parameters = array('status' => $message);
$status = $connection->post('statuses/update', $parameters);

?>
halfer
  • 19,824
  • 17
  • 99
  • 186
user2738520
  • 1,341
  • 4
  • 13
  • 17

1 Answers1

0

I don't see anything that references future postings in the Twitter API documentation, so I'd imagine it is not possible.

I think the best way to handle this would be to store the tweet and the posting time in a database, and then have a PHP script run automatically and submit the Tweets at the correct time.

You can accomplish this by writing a script that contains the logic and then, if you're on a *nix server, using cron to execute the script at periodic intervals. Some additional information about using cron and PHP can be found here.

Hope this helps!

Note: I'm not familiar with the Twitter API at all, so I'm not sure how it would work with authentication and scheduling tweets in the future. I imagine that if the user provides permission, you can post the tweet as described above, but it's just a SWAG.

Community
  • 1
  • 1
Pete
  • 467
  • 7
  • 20
  • Thank for your answer! I think we can scheduling tweets, i just found out this website: [Click Here](http://laterbro.com/) – user2738520 Sep 10 '13 at 03:28
  • I'm not sure if the scheduling is done through the API, though. The posting obviously is, but not sure about the scheduling. – Pete Sep 10 '13 at 14:43