topical media & game development

talk show tell print

mashup-amazon-10-10-02-Wishlist-getdata.aspx.cs / cs



  using System;
  using System.Data;
  using System.Configuration;
  using System.Collections;
  using System.Web;
  using System.Web.Security;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  using System.Web.UI.WebControls.WebParts;
  using System.Web.UI.HtmlControls;
  using System.Xml;
  
  public partial class getdata : System.Web.UI.Page
  {
      protected void Page_Load(object sender, EventArgs e)
      {
          // If this page was passed any keywords, then GetResults
          GetResults();
      }
  
      void GetResults()
      {
          string strURI = "";
  
          // Is this a Youtube api call or an Amazon call? 
          switch(Request.Params["api"]){
              case "youtube":        
                  // a YouTube request
                  strURI = "http://www.youtube.com/api2_rest?method=youtube.videos.list_by_tag&dev_id=[YOUR ID HERE]&tag=" + Request.Params["tag"];
                  break;
              case "ebay":
                  // an ebay request
                  strURI = "http://rest.api.ebay.com/restapi?CompatibilityLevel=445&CallName=GetSearchResults&RequestToken=[YOUR TOKEN HERE]&RequestUserId=[YOUR ID HERE]&Schema=1&Currency=1&TrackingProvider=1&TrackingId=1889305&SearchInDescription=1&MaxResults=10&Query=" + Request.Params["query"]; ;
                  break;
              default:
                  // Build an Amazon URI
                  strURI = amazonUtility.BuildAmazonURI(Request.QueryString);
                  break;        
          }
          
          // Obtain the data
          XmlDocument myDoc = webUtility.GetUri(strURI);
  
          // If the data passed back is ok
          if (myDoc != null)
          {
              Response.Clear();
              Response.ContentType = "text/xml";
              Response.Write(myDoc.InnerXml);
              Response.End();         
          }
      }
  }
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.