Ejemplo n.º 1
0
        public static void Run()
        {
            var templatedUriRequestBuilder = new TemplatedUriRequestBuilder(new RequestFactory());
            templatedUriRequestBuilder.Uri = Services.FlickrUri;

            dynamic flickr = new RestClient(templatedUriRequestBuilder, new ResponseProcessor(new StandardResultBuilder(RestService.Json)));
            flickr.apiKey = Services.FlickrApiKey;

            Console.WriteLine("Searching photos tagged with 'seattle'...");

            dynamic photosOptions = new JsonObject();
            photosOptions.tags = "seattle";
            photosOptions.per_page = 4;

            dynamic search = flickr.Photos.Search(photosOptions);
            WritePhotos(search.Result);

            Console.WriteLine();
            Console.WriteLine();

            Console.WriteLine("Searching interesting photos...");

            dynamic interestingnessOptions = new JsonObject();
            interestingnessOptions.per_page = 4;

            dynamic listing = flickr.Interestingness.GetList(interestingnessOptions);
            WritePhotos(listing.Result);
        }
Ejemplo n.º 2
0
        public static void Run()
        {
            var templatedUriRequestBuilder = new TemplatedUriRequestBuilder(new RequestFactory());
            templatedUriRequestBuilder.Uri = Services.BingSearchUri;

            dynamic bingSearch = new RestClient(templatedUriRequestBuilder, new ResponseProcessor(new StandardResultBuilder(RestService.Json)));
            bingSearch.appID = Services.BingApiKey;

            Console.WriteLine("Searching Bing for 'seattle'...");

            dynamic searchOptions = new JsonObject();
            searchOptions.Query = "seattle";
            searchOptions.Sources = new string[] { "Web", "Image" };
            searchOptions.Web = new JsonObject("Count", 4);
            searchOptions.Image = new JsonObject("Count", 2);

            dynamic search = bingSearch.invoke(searchOptions);
            dynamic searchResponse = search.Result.SearchResponse;

            foreach (dynamic item in searchResponse.Web.Results) {
                Console.WriteLine(item.Title);
                Console.WriteLine(item.DisplayUrl);
                Console.WriteLine();
            }
            foreach (dynamic item in searchResponse.Image.Results) {
                Console.WriteLine(item.Title);
                Console.WriteLine(item.MediaUrl);
                Console.WriteLine();
            }
        }
Ejemplo n.º 3
0
        public static void Run()
        {
            var templatedUriRequestBuilder = new TemplatedUriRequestBuilder(new RequestFactory());
            templatedUriRequestBuilder.Uri = Services.GoogleSearchUri;

            dynamic googleSearch = new RestClient(templatedUriRequestBuilder, new ResponseProcessor(new StandardResultBuilder(RestService.Json)));

            Console.WriteLine("Searching Google for 'seattle'...");

            dynamic searchOptions = new JsonObject();
            searchOptions.q = "seattle";

            dynamic search = googleSearch.invokeAsync(searchOptions);
            search.Callback((RestCallback)delegate()
            {
                dynamic results = search.Result.responseData.results;
                foreach (dynamic item in results)
                {
                    Console.WriteLine(item.titleNoFormatting);
                    Console.WriteLine(item.url);
                    Console.WriteLine();
                }
            });

            while (search.IsCompleted == false)
            {
                Console.WriteLine(".");
                Thread.Sleep(100);
            }
        }
Ejemplo n.º 4
0
        public static void Run()
        {
            AmazonUriSigner signer = new AmazonUriSigner(Services.AmazonAccessKey, Services.AmazonSecretKey);

            var templatedUriRequestBuilder = new TemplatedUriRequestBuilder(new RequestFactory());
            templatedUriRequestBuilder.Uri = Services.AmazonUri;
            templatedUriRequestBuilder.SetUriTransformer(signer);

            dynamic amazon = new RestClient(
                templatedUriRequestBuilder,
                new ResponseProcessor(new StandardResultBuilder(RestService.Xml)));

            dynamic searchOptions = new JsonObject();
            searchOptions.SearchIndex = "Books";
            searchOptions.Keywords = "Dynamic Programming";

            dynamic search = amazon.ItemSearch(searchOptions);
            dynamic bookList = search.Result;

            foreach (dynamic book in bookList.SelectAll("Item")) {
                Console.WriteLine(book.ASIN + " : " + book.ItemAttributes.Title);
            }
        }