Post twitter tweets from php with tinyurl links
Author: admin / Category: Programming SecretsMy boss just asked me to look for a script, capable of adding content to a twitter page from a site’s database. Very important, the twitter post needs to contain links to the website posts. And because they need to be as short as possible, i used the tinyurl API to dynamically create the short version of the urls. Here is a very simple code how to post to twitter some content:
require(‘twitterAPI.php’);
$twitter_username =’YourTwitterUsername’;
$twitter_psw =’YourTwitterPassword’;$url = ‘YourLink’;
$tweet = ‘YourTweet’;
$url = TinyURL($url);
$twitter_status=postToTwitter($twitter_username, $twitter_psw, $tweet.’ : ‘.$url);function TinyURL($u){
return file_get_contents(‘http://tinyurl.com/api-create.php?url=’.$u);
}
You can download the TwitterApi from twitterAPI.php
















