Posts Tagged ‘Twitter’
Shorten URLs and post to Twitter with PHP and cURL
I recently had the task of automatically “tweeting” when a new article was posted to one of the websites I had built, it turns out to be a pretty simple operation thanks to both Twitter and Bit.ly providing a straight forward API. An account with Bit.ly does have to be opened to obtain an API key.
I decided to use the built-in cURL functionality of PHP for interacting with the APIs. This code uses some of the JSON functions introduced in PHP 5.2.0 so a recent install of PHP is required as the Bit.ly API responds with a JSON string. On to the code…
(more…)
