Showing posts with label api. Show all posts
Showing posts with label api. Show all posts

Monday, June 8, 2009

WWDC Day One

While I can't disclose all that I learned from the WWDC, due to the NDA, I will say that it has been amazing.  Apple has not only put on a well oiled conference, but the new product lines as well as tools and resources available have just been amazing.

In case you didn't catch today's keynote here are some highlights:

  • Macbook Pros now come in 13in, 15in, 17in models
  • Macbook Pros can have up to 8gb of RAM
  • Macbook Pros have SD Slot
  • Snow Leopard has an almost seamless connection to Exchange
  • Snow Leopard and iPhone SDK use 90% of the same framework/APIs
  • Prices have dropped tremendously
  • iPhone 3g are now only $99
  • iPhone 3gp[s] are coming in 16gig/32gig
  • iPhone 3.0 now supports voice dialing, improved camera (with autofocus and highlighting), video camera with in-context editing and digital compass.
Obviously there was much more discussed so to get all the juicy details check out the keynote video.  

Monday, August 25, 2008

Label Me

Of the API features that Google offers for their Blogger service the one that I was most surprised to see missing is a method to retrieve all the tags(category) for a blog. Though listed in their query parameters is the syntax for search by tag/category, the "cloud" was missing. The below code takes care of this missing feature.

::NOTE::
This class will be rolled into my helper classes soon.

class CW_Blog_Util {
const BLOGGER_URL = 'http://www.blogger.com/feeds/blogId/posts/default';

/**
* associative array holding blog tbl properties
*
* @var array
*/
private $_blogs = array();

/**
* blog title
*
* @var string
*/
private $_title = "";

private $_gDataQuery = null;

private $_gQuery = null;

public function __construct() {
$this->_gQuery = new Zend_Gdata();
}

public function getAllEntries() {

$query = $this->_getGdataQuery();
$feed = $this->_gQuery->getFeed($query);

return $feed;
}

public function getLatestBlog() {

$query = $this->_getGdataQuery();
$feed = $this->_gQuery->getFeed($query);

return $feed->current();
}

public function getBlogListByTag($tag) {

$query = $this->_getGdataQuery();
$query->setCategory($tag);

$feed = $this->_gQuery->getFeed($query);

return $feed;
}

public function getBlogLabels() {

$labels = array();

foreach ($this->getAllEntries() as $attr) {

for ($i = 0; $i < count($attr->category); $i++) {
$labels[] = $attr->category[$i]->term;
}
}

return array_count_values($labels);
}

private function _getGdataQuery() {
$this->_gDataQuery = new Zend_Gdata_Query(self::BLOGGER_URL);

return $this->_gDataQuery;
}

}

// Usage
$blogs = new CW_Blog_Util();

foreach ($blogs->getBlogLabels() as $label => $count) {
print "Label {$label}
";
}

Monday, August 4, 2008

Access XML Nodes From Namespaces With Zend Framework

One of the requirements for a project that I am working on is that a "weather" module display on on of the main pages.  At first glance this should be pretty easy.  While working on it I noticed that I wanted to access more of the information that the feed had available.  I found plenty of tutorials on how to access the node values using SimpleXML, but I couldn't find what I was looking for utilizing Zend Framework.

After a quick response from the mailing list and references to the PHP online manual I came up with the solution.

Thanks to Pádraic Brady for the assistance.


Zend_Feed::registerNamespace('yweather','http://xml.weather.yahoo.com/ns/rss/1.0');
Zend_Feed::registerNamespace('geo','http://www.w3.org/2003/01/geo/wgs84_pos#');

$feed = Zend_Feed::import("http://weather.yahooapis.com/forecastrss?p=38105");

// Conditional Codes: http://developer.yahoo.com/weather/#codes
$condition = $feed->current()->{'yweather:condition'};
$text      = $condition->getDOM()->getAttribute('text');
print "Text {$text}
";

$astronomy = $feed->{'yweather:astronomy'};
$text      = $astronomy->getDOM()->getAttribute('sunrise');
print "Sunrise Attribute {$text}
";
          
$lat  = $feed->current()->{'geo:lat'};
$text = $lat->getDOM()->nodeValue;
print "Latitude {$text}
";