Archive for the ‘Zend Framework’ tag
Shortening URLs using bit.ly API and PHP+Zend Framework
Recently for Topify I needed to shorten some long urls (our invite links) and my obvious choice of shortener was bit.ly. I tried looking for PHP wrapper for their API, but only found this project which was way more than I needed. So I’ve decided to write my own simple client using the Zend Framework HTTP Client. Here’s the result:
<?php
function bitly_shorten ($url) {
$client = new Zend_Http_Client('http://api.bit.ly/shorten');
$client->setParameterGet(array(
'version' => '2.0.1',
'longUrl' => $url,
'login' => 'arikfr',
'apiKey' => 'R_03feadf27c1c7c1a1ac3c3e7d6d41a27'
));
$response = $client->request();
if ($response->isSuccessful() ) {
$phpNative = Zend_Json::decode($response->getBody());
if ($phpNative['errorCode']==0) {
return $phpNative['results'][$url]['shortUrl'];
}
}
return "";
}
?>
As I said – it’s simple. There’s a lot more to do with it, but it serves the purpose I needed it for and I think it might be useful for others who only want to shorten some urls. If you need more than that, you might want to take a look at the above mentioned project.
Arik
Handling RSS Feeds with PHP using Zend_Feed
Zend Framework is becoming a very comprehensive set of widely needed components for PHP development. As other frameworks offer similar components, one of Zend’s Framework greatest strengthens is the fact that you can use its components as stand alone components and not only as part of the MVC structure. In this post I will show how you can easily use it’s Zend_Feed component to merge feeds.
Recently I though of making one combines RSS feed of both of my blogs and my twitter updates. There are some RSS merging services out there, and there’s also Yahoo pipes which seems that it’s most useful ability is to do various RSS tweaking tasks. As part of my playing around with the Zend Framework, I’ve decided to make this merged RSS feed using the Zend_Feed component. Actually at the end I’ve realized that this merged feed idea is quite useless, but at least this post came out of it
Most of the basic actions, like importing an RSS feed, creating an RSS feed and more are covered in the Zend Framework manual. In this post I will elaborate more on the more advanced topics, like sorting and merging RSS feeds but I will also go briefly over the more basic stuff as well.
So let’s begin.