
The Daylife Cookbook is a collection of recipes to help you bootstrap applications that use the Daylife platform (DayPI).
These recipes come from Daylifers and the cookbook community, with entries ranging from sample code to tutorials, half baked ideas, and spotlights of the latest deployments of the DayPI.
Feel free to share, steal, criticize, applaud, and feed back!
Daylife is a perfect fit for our strategy of presenting the best and most tightly focused content, whether it is produced by us at USA TODAY or anywhere else on the Web. It helps us provide our readers with a full 360-degree view of a given topic, and adds depth and richness to niche areas important to our readers and advertisers.- Jeff Webber, SVP, USAToday.com
You guys have what seems like an amazingly powerful and easy to use API, we're pretty excited about playing with it and possibly integrating it with Hubdub. - Tom Griffith, Hubdub.com
It's amazing how simple this is to integrate into django. When a view is creating a page, it just calls a thin wrapper function that I put around the daypi module. - Bracket Boy
I found the Daylife API for PHP really easy to use, and coded something up quickly for my site, Brooklyn and Beyond - Brooklyn & Beyond
This tool makes it really easy to get a quick look or dive in deep thanks to our partner Daylife, who built a comprehensive service that yields up-to-the-minute results - The Washington Post
I was trying to make it work by using Google News RSS feeds but turned out impossible since they don't organize their data in the feeds. I now know its possible with the Daylife API - Akash Xavier
Home
| Get Credentials for the DayPI
| Daylife.com
| FAQ's
| Terms of Use
© 2008 Daylife, Inc.

With Caching and Images
This version extends the search method to be able to handle the DayPI search_getRelatedImages API method.
It is Essentially similar to the other calls. The only thing to bear in mind is that you have to use the overloaded version of the Search function which takes a source filter. Without your source filter ID getting images is rather messy. The resulting list of DayImage objects provide properties on most of the relevant XML data. Do bear in mind however that DayImageObject.prop_Credit and DayImageObject.prop_Source.prop_Name may not be the same. For example in the case of Getty Images AFP the credit will be AFP/Getty Images while the Source name will be Getty Images.
To download the image in a given width you could use the following code snippet
public System.Drawing.Image DownloadImage(string ImageID, int Width)
{
System.Net.WebRequest APIRequest;
System.Net.WebResponse APIResponse;
System.Drawing.Image APIImage;
string ImageURL;
ImageURL = string.Concat("http://cache.daylife.com/imageserve/", ImageID, "/", Width.ToString(), "x.jpg");
APIRequest = System.Net.WebRequest.Create(ImageURL);
APIRequest.Timeout = 60000;
APIResponse = APIRequest.GetResponse();
APIImage = System.Drawing.Image.FromStream(APIResponse.GetResponseStream());
APIResponse.Close();
APIResponse = null;
APIRequest = null;
return APIImage;
}
Extract from Usageexample.txt for how to call the search images method.
Query = "Amitabh Bachchan";
DayLifeSearchResult = RequestAPI.Search(DayRequest.enum_DayRequestSearchType.SearchGetRelatedImages, Query, DayRequest.enum_SortOrder.relevance, null, StartDate, EndDate, Offset, Limit, "Your Source Filter ID");
if (DayLifeSearchResult.prop_Success)
{
foreach (DayLifeAPI.Data.DayImage RelatedImage in DayLifeSearchResult.prop_SearchImagesList)
{
// Do something with
//RelatedImage.prop_ImageID;
//RelatedImage.prop_Caption;
//RelatedImage.prop_Credit;
//RelatedImage.prop_Height;
//RelatedImage.prop_ImageDate;
//RelatedImage.prop_ThumbURL;
//RelatedImage.prop_ImageURL;
//RelatedImage.prop_DaylifeURL;
if (RelatedImage.prop_Source.prop_IsValid)
{
////RelatedImage.prop_Source.prop_SourceID
////RelatedImage.prop_Source.prop_Name
////RelatedImage.prop_Source.prop_DaylifeURL
////etc...
}
//etc...
}
}
else
{
MessageBox.Show(string.Concat("Failed, Error Code = ", DayLifeSearchResult.prop_ResultCode));
MessageBox.Show(string.Concat("Failed, Error Message = ", DayLifeSearchResult.prop_ResultMessage));
}
Cheers
Tikiri