Scheduled posting to twitter in PHP cURL -


i able post tweets twitter account using twitter api. using curl. want post tweets on scheduled date/time. know possible no idea how ?

code :

<?php   $twitter_consumer_key = 'xxx';   $twitter_consumer_secret = 'xxx';   $twitter_access_token = 'xxx';   $twitter_access_token_secret = 'xxx';   $twitter_version = '1.0';   $sign_method = 'hmac-sha1';   $status="helloworld";   $url = 'https://api.twitter.com/1.1/statuses/update.json';   $param_string = 'oauth_consumer_key=' . $this->twitter_consumer_key .         '&oauth_nonce=' . time() .         '&oauth_signature_method=' . $this->sign_method .         '&oauth_timestamp=' . time() .         '&oauth_token=' . $this->twitter_access_token .         '&oauth_version=' . $this->twitter_version .         '&status=' . rawurlencode($status);    //generate signature base string post   $base_string = 'post&' . rawurlencode($url) . '&' . rawurlencode($param_string);   $sign_key = rawurlencode($this->twitter_consumer_secret) . '&' . rawurlencode($this->twitter_access_token_secret);    //generate unique signature   $signature = base64_encode(hash_hmac('sha1', $base_string, $sign_key, true));   $curl_header = 'oauth oauth_consumer_key=' . rawurlencode($this->twitter_consumer_key) . ',' .       'oauth_nonce=' . rawurlencode(time()) . ',' .       'oauth_signature=' . rawurlencode($signature) . ',' .       'oauth_signature_method=' . $this->sign_method . ',' .       'oauth_timestamp=' . rawurlencode(time()) . ',' .       'oauth_token=' . rawurlencode($this->twitter_access_token) . ',' .         'oauth_version=' . $this->twitter_version;    $ch = curl_init();   //twitter post   curl_setopt($ch, curlopt_httpheader, array('authorization: ' . $curl_header));   curl_setopt($ch, curlopt_verbose, 1);   curl_setopt($ch, curlopt_url, $url);   curl_setopt($ch, curlopt_returntransfer, 1);   curl_setopt($ch, curlopt_post, 1);   curl_setopt($ch, curlopt_postfields, 'status=' . rawurlencode($status));    $twitter_post = json_decode(curl_exec($ch));   curl_close($ch);   print_r($twitter_post); ?> 

what changes need make post tweet on scheduled date/time

you may use cron jobs.

http://www.thesitewizard.com/general/set-cron-job.shtml explanations.

https://www.setcronjob.com/ free service if don't have cron option on hosting (usually shared hosting)

enjoy !


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -