Latest: Express.js Route Middleware

Content with Style

Web Technique

CwS blog posts now on twitter

by Pascal Opitz on January 29 2009, 08:00

Posts from our blog will now automatically pop up on Twitter.

This is only a couple of lines of code, thanks to the API wrapper that Zend Framework now offers, but also thanks to the TinyURL API:


// TinyURL for the blog post
$client = new Zend_Http_Client($config->tinyurl->endpoint);
$client->setParameterGet('url', $url);
$response = $client->request('GET');
$tiny_url_response = $response->getBody();

// TinyURL into the message
$message = $message . ' ' . $tiny_url_response;

// Twitter
$twitter = new Zend_Service_Twitter($config->twitter->user, $config->twitter->password);        
$twitter->status->update($message);

So feel free to follow us, even though twittering to ME only makes sense if it happens automatically, as I personally am no big fan of messages like "I am going outside now" or anything like that.

Comments

  • Out of curiosity, do you use other Zend Framework components? Our MVC implementation? ,Wil

    by Wil Sinclair on February 5 2009, 00:05 - #

  • Hi Will,
    yes, the whole blog is running on Zend Framework.

    require_once('Zend/Loader.php'); Zend_Loader::loadClass('Zend_Cache'); Zend_Loader::loadClass('Zend_Config_Ini'); Zend_Loader::loadClass('Zend_Controller_Front'); Zend_Loader::loadClass('Zend_Controller_Router_Rewrite'); Zend_Loader::loadClass('Zend_Session_Namespace'); Zend_Loader::loadClass('Zend_Http_Cookie'); Zend_Loader::loadClass('Zend_Db'); Zend_Loader::loadClass('Zend_Feed_Rss'); Zend_Loader::loadClass('Zend_Layout'); Zend_Loader::loadClass('Zend_Registry'); Zend_Loader::loadClass('Zend_Mail'); Zend_Loader::loadClass('Zend_Mail_Transport_Smtp'); Zend_Loader::loadClass('Zend_Log'); Zend_Loader::loadClass('Zend_Log_Exception'); Zend_Loader::loadClass('Zend_Log_Writer_Stream'); Zend_Loader::loadClass('Zend_Json'); Zend_Loader::loadClass('Zend_Http_Client'); Zend_Loader::loadClass('Zend_Service_Twitter'); Zend_Loader::loadClass('Zend_XmlRpc_Client');

    This is part of our bootstrap file. We're making heavy use of the MVC implementation. Behind the scenes, elsewhere is coming from delicious, but also the admin tool is talking to various services to ping sitemaps, technorati, performing XHTML validations and so on.

    Cache wise I wanted to got for Zend_Cache_Frontend_Page, but couldn't get it to work at all. Instead I wrote two plugins, a cache reader and a cache writer, that implement caching through Zend_Cache_Core. Close control enables me to serve 304s but not cache AJAX pages.

    I hope this gives a little insight?

    by Pascal Opitz on February 5 2009, 07:09 - #

Leave your comment

Comments are moderated.
Tags allowed: a, strong, em, code, ul, ol, li, q, blockquote, br, p

Advertisement
Advertisement