Categories
Development

YQL is my new BFF

YQL

YQL, Yahoo’s SQL-like language that provides straightforward ways to mash up different APIs into one data source for use in applications has been around for a few months now. In that time I’ve found it to be extremely useful and easy to work with in numerous projects. However,  the service got 10 ninjas better last week they added the ability to insert, update and delete to the service as well.

In just a few minutes I was able to take an existing news app that I had created in the past and using the YQL service had it sending out tweets to Twitter as well as including a shortened URL courtesy of the bit.ly API.

Just feed the following Twitter status update to the YQL Console and it’ll create the REST query that you can use in your script:

use 'http://www.yqlblog.net/samples/twitter.status.xml';
insert into twitter.status (status,username,password)
values ("Playing with INSERT UPDATE and DELETE in YQL", "twitterusername","twitterpassword")
Categories
Uncategorized

My Mom-mom

Sadly my grandmother passed away on Sunday morning. She was the best grandmother to my brothers and we’ll miss her very very much. What I’ll remember most about her is the fun we had when she would baby sit us when we were little.

Growing up my brothers and I had a number of baby sitters who refused to babysit again (looking back there should be no shame for not returning), but she always seemed to have such a good time with us. Whether it was the time we destroyed the kitchen trying to make cupcakes, or tying her to the couch when she dozed off for just a few minutes, to flooding the bathroom floor just for fun that she would later slip on (so sorry for that one mom-mom), she would never got angry at us or tell our parents how bad we behaved on that given night.

Wow, actually now that I’m writing this I’m remembering so much more good stuff we did with her. She was cool enough to play with us and our Star Wars and G.I. Joe toys. How many grandmoms knew how cool Boba Fet was? She’d take us to the mall all the time, to Collector’s Cabin to buy Jose Canseco rookie cards, read nursery rhymes to us from the ancient book nursery rhyme book we had, and look for gold bug hidden in the other book too (gold bug was like Waldo, but a golden bug). Oh, and also sewing on strawberry cartons or paper plates (sounds weird, but it was fun stuff).

And she and my grandfather bought me the Mac LC which was the coolest gift that I’ve ever gotten to this day. Probably the biggest reason why I do what I do for a living today.

We really had a lot of good times with her and that will certainly be missed, but not forgotten. Oh and her apple tarts that she would always bake for us were awesome too.

Categories
Development

bit.ly API

With the 140 character limit that comes with developing a Twitter app, I needing a URL shortening service with a simple, easy to use API. Conveniently the bit.ly API works great if you are looking for s simple URL shortener for dynamic use.

Just had to sign up a free account, then spent a few minutes reading over the bit.ly API documentation. Just send a simple REST request and you get a simple JSON response. Doesn’t really get much simpler than that. An XML response is also available as well.

Very cool API and one that worked perfectly for the task at hand.

Categories
Development

Yahoo! Term Extraction Web Service

Just finished up using one of my favorite and what seems to be little well known web service, the Term Extraction from the folks a Yahoo! You feed it some content and it returns a list of significant words from the content. This simple service can be incredibly useful.

For instance I recently used this service to scan an article on a site and using the words that it returns, as tags to pull relevant photos from Flickr to go along with the article. So in this case I used it to pull tags from a body of text, very cool. You can also use YQL to make calls to it as well.

Categories
Development

Pulling Flickr photos using YUI Get Utility with photo_id

Atlantic Cape Community College has been using a Flickr Pro account to store and share our photos (Flickr Pro at $24.95/yr is a steal) and also like to incorporate those photos into our news releases from time to time. 

So I began working an a little script that would call the flickr.photos.getSizes API Method using YQL to return the info to display the photo (dimensions, source, etc.) in an easy to consume JSON object. Oh yeah, and also had to do all this using the YUI Get Utility since our server at the moment doesn’t have cURL installed.

So first I went to the YQL console (it’s awesome to be sure to check it out) to generate the HTTP to call the JSON we’re looking for using the flickr.photos.getSizes API Method. Here is the the YQL I fed it:

select * from flickr.photos.sizes where photo_id = "414195174"

and it gave me this wonderful REST Query (again YQL is awesome):

http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20flickr.photos.sizes%20where%20photo_id%20%3D%20%223591600467%22&format=json&callback=cbfunc

this returns the following JSON info:

cbfunc({
 "query": {
  "count": "6",
  "created": "2009-06-08T06:37:37Z",
  "lang": "en-US",
  "updated": "2009-06-08T06:37:37Z",
  "uri": "http://query.yahooapis.com/v1/yql?q=select+*+from+flickr.photos.sizes+where+photo_id+%3D+%223591600467%22",
  "diagnostics": {
   "publiclyCallable": "true",
   "url": {
    "execution-time": "149",
    "content": "http://api.flickr.com/services/rest/?method=flickr.photos.getSizes&photo_id=3591600467&page=1&per_page=10"
   },
   "user-time": "154",
   "service-time": "149",
   "build-version": "1678"
  },
  "results": {
   "size": [
    {
     "height": "75",
     "label": "Square",
     "media": "photo",
     "source": "http://farm3.static.flickr.com/2447/3591600467_1f25e40ce1_s.jpg",
     "url": "http://www.flickr.com/photos/accc_cr/3591600467/sizes/sq/",
     "width": "75"
    },
    {
     "height": "100",
     "label": "Thumbnail",
     "media": "photo",
     "source": "http://farm3.static.flickr.com/2447/3591600467_1f25e40ce1_t.jpg",
     "url": "http://www.flickr.com/photos/accc_cr/3591600467/sizes/t/",
     "width": "84"
    },
    {
     "height": "240",
     "label": "Small",
     "media": "photo",
     "source": "http://farm3.static.flickr.com/2447/3591600467_1f25e40ce1_m.jpg",
     "url": "http://www.flickr.com/photos/accc_cr/3591600467/sizes/s/",
     "width": "202"
    },
    {
     "height": "500",
     "label": "Medium",
     "media": "photo",
     "source": "http://farm3.static.flickr.com/2447/3591600467_1f25e40ce1.jpg",
     "url": "http://www.flickr.com/photos/accc_cr/3591600467/sizes/m/",
     "width": "420"
    },
    {
     "height": "1024",
     "label": "Large",
     "media": "photo",
     "source": "http://farm3.static.flickr.com/2447/3591600467_1f25e40ce1_b.jpg",
     "url": "http://www.flickr.com/photos/accc_cr/3591600467/sizes/l/",
     "width": "861"
    },
    {
     "height": "2400",
     "label": "Original",
     "media": "photo",
     "source": "http://farm3.static.flickr.com/2447/3591600467_1fe814e144_o.jpg",
     "url": "http://www.flickr.com/photos/accc_cr/3591600467/sizes/o/",
     "width": "2017"
    }
   ]
  }
 }
});

So now we have an easy to use REST Query to use with all the info that we just so happen to need from Flickr.

Now I needed to create a little Javascript using the YUI Get Utility to consume the REST Query that we just built.

Here’s a basic version of the script I wrote:

function jsonFlickrApi(rsp){
 
		if (rsp.query.count == 0){
			return;
		} else {
 
			var container = document.getElementById('article-photo');
 
			// create elements
 
			var photoAnchor = document.createElement('a');
			var photoImg = document.createElement('img');
 
			// set attributes
			photoAnchor.setAttribute('href', rsp.query.results.size[3].source);
			photoAnchor.setAttribute('rel', 'lightbox');
 
			photoImg.setAttribute('src', rsp.query.results.size[2].source);
			photoImg.setAttribute('width', rsp.query.results.size[2].width);
			photoImg.setAttribute('height', rsp.query.results.size[2].height);
 
			// append to DOM
			photoAnchor.appendChild(photoImg);
 
			container.appendChild(photoAnchor); 
 
		}
    }
 
    var objTransaction = YAHOO.util.Get.script("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20flickr.photos.sizes%20where%20photo_id%20%3D%20%223591600467%22&format=json&callback=jsonFlickrApi");

The function jsonFlickrAPI gets called when the JSON has loaded since it’s sent along with the Get request as the callback function. Then we just check if anything has been returned from the REST call before proceeding by checking the count returned.

Then create some DOM nodes and attach them to a div in our HTML. That’s really about it.

Next, I’m going to improve this to pull all relevant photos with a certain tag(s) from our Flickr account to dynamically create relevant galleries.

Categories
Design Development

sjrates.com

sjrates.comJust finished up building www.sjrates.com. It’s a site that makes comparing local rates easy and convenient for those in Southern New Jersey.

The client approached with with a sound idea of making it easier for local people to compare rates. Instead of having to search each financial institution individually, he wanted to group them all together to save users time.

The site makes use of many technologies.  Notable uses include:

Working with the client was a real pleasure. I thought we had a great client – developer relationship and I this really helped contribute to a really nice finished project.