Using iStockphoto user atom feeds

31. August 2009 13:53 by Brian in Projects - Comments: (0)

View Portfolio

On a new website for Add Image (http://www.addimage.net/) we added a stock gallery which uses the Atom feeds from www.iStockPhoto.com  which allow a user to use a data feed of their 10 latest images.

The datafeed is in Atom format. Using Microsoft Linq and C# I wrote the following code which grabs the users latest images and displays them on a web page complete with links back to each image to purchase.

You need to change the ID which is set to 275125 in this demo to be your own iStockPhoto user ID.

 


<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="utf-8" Debug="false"%>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Linq" %>
<%@ Import Namespace="System.Xml.Linq" %>
<script runat="server">
protected void Page_Load(Object Src, EventArgs E)
{

XmlReaderSettings settings = new XmlReaderSettings();
XmlUrlResolver resolver = new XmlUrlResolver();
XmlReader reader = XmlReader.Create("http://www.istockphoto.com/istock_myfiles_rss.php?ID=275125", settings);
XNamespace ns = XNamespace.Get("http://purl.org/atom/ns#");
XDocument feed = XDocument.Load(reader);
var items = from item in feed.Descendants(ns + "entry")

select new {Title = item.Element(ns + "title").Value, Link = item.Element(ns + "link").Attribute("href").Value, Summary = (string)item.Element(ns + "content")} ;

Repeater1.DataSource = items;
Repeater1.DataBind();

}
public string makeimagelink(string inval) {

return inval.Replace("http://www.istockphoto.com/file_closeup.php?id=","").Replace("&refnum=275125&source=rssuserimages","");
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
.photobox { height: 140px; padding: 0px; margin: 10px 0px 50px 0px; width:20%; float: left; text-align:center; background:#FFFFFF; }
.photobox a { text-decoration:none; }
.imagebox{ height:120px; margin-top:5px;}
</style>
</head>
<body>
<asp:Repeater id="Repeater1" runat="server" >
<ItemTemplate>
<div class="photobox">
<a href="<%# DataBinder.Eval(Container.DataItem, "Link") %>" target="_blank">
<div class="imagebox"><img src="http://www.istockphoto.com/file_thumbview_approve/<%# makeimagelink(DataBinder.Eval(Container.DataItem, "Link").ToString()) %>/istockphoto.jpg" border="0" style="margin-bottom: 10px;"/></div>
<%# DataBinder.Eval(Container.DataItem, "Title") %></a></div>
</ItemTemplate>

</asp:Repeater>
</body>
</html>

Purbeck Airgun Club

26. August 2009 14:19 by Brian in Projects - Comments: (0)

On Wednesday evenings I will now be helping to run a new airgun club in Swanage

I have finished a new website for the club using blogengine.net and it is online at www.purbeckairgunclub.co.uk

Tags: - Posted in: Projects

One of my websites on TV

15. August 2009 19:53 by Brian in Projects - Comments: (0)

One of the websites I built last year, English Custom Stamps has been featured on a TV shopping channel !

http://www.englishcustomstamps.com/

English Custom Stamps on TV 

English Custom Stamps on TV

Tags: - Posted in: Projects

RecentComments

Comment RSS

 

 

About the Blog

Welcome to my space on the web! I made this site as a central place with various links and information for my various hobbies, sports and interests and for anyone who knows me to find out what I have been doing since I left school.

My LinkedIn Profile

My Flickr Profile

My Twitter Profile

Powered by BlogEngine.NET 1.6.0.0 - Theme by apexweb - Log in