I have a client with a Wordpress blog. They are posting pictures to Twitter after emailing to blog as a post manually. The process
1. Email picture to Wordpress
2. Post is created
3. Manually shorten url using bit.ly
4. Post to twitter.
I would like to automate it. The plug currently generates a short url using the domain, bit.ly would be shorter. Here is the plug in code:
Code:
// Generate URL
$url = preg_replace('/\/$/', '', (get_option('twitter_image_host_override_url_prefix') ? get_option('twitter_image_host_override_url_prefix') : get_option('siteurl'))).'/'.$tag;
Here is the code I found to generate the short url. Having trouble combining the two.
function shortUrl ($url)
{
$bitlyUser = 'TEST';
$apiKey = 'API_KEY';
$ch = curl_init();
//cURL options
curl_setopt($ch, CURLOPT_URL, 'http://api.j.mp/v3/shorten?login=' . $bitlyUser . '&apiKey=' . $apiKey .'&uri=' . htmlspecialchars($url) . '&format=txt');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//Execution
$ret = curl_exec($ch);
curl_close($ch);
return $ret;
Any ideas? Appreciate it. Thanks!
Billy
Last edited by chrishirst; 03-04-2011 at 03:56 PM..
|