From 1d26458017b53c3e217c24b4d91835a28c5eee14 Mon Sep 17 00:00:00 2001 From: Vladimir Latis Date: Thu, 27 Mar 2014 12:12:05 +0200 Subject: [PATCH] allowed the usage of default web proxy --- DiffbotApi/Diffbot.cs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/DiffbotApi/Diffbot.cs b/DiffbotApi/Diffbot.cs index 21fa76e..448de52 100644 --- a/DiffbotApi/Diffbot.cs +++ b/DiffbotApi/Diffbot.cs @@ -1,11 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Net; -using System.Xml.Serialization; +using System.Collections.Generic; using System.IO; +using System.Net; +using System.Text; using System.Web; +using System.Xml.Serialization; namespace DiffbotApi { public class Diffbot @@ -31,7 +29,11 @@ public Frontpage Frontpage(string url) { using (WebClient wc = new WebClient()) { - wc.Proxy = _proxy; + if (_proxy != null) + { + wc.Proxy = _proxy; + } + wc.Encoding = Encoding.UTF8; string xmlString = wc.DownloadString(getQueryUrl(FRONTPAGE_API_SUFFIX, url)); XmlSerializer ser = new XmlSerializer(typeof(Frontpage)); @@ -57,7 +59,11 @@ public Article Article(string url, bool comments = false, bool html = false, boo if (tags) args.Add(new OptionalParameter() { Name = "tags", Value = "true" }); - wc.Proxy = _proxy; + if (_proxy != null) + { + wc.Proxy = _proxy; + } + wc.Encoding = Encoding.UTF8; string jsonString = wc.DownloadString(getQueryUrl(ARTICLE_API_SUFFIX, url, args.ToArray())); return new Article(jsonString);