Permalink
Browse files

Initial commit.

  • Loading branch information...
tansey committed May 30, 2011
0 parents commit 1b4ebb8c384abee2739b403269e5ca8292f730e6
Showing with 40,236 additions and 0 deletions.
  1. +20 −0 DiffbotApi.sln
  2. BIN DiffbotApi.suo
  3. +82 −0 DiffbotApi/Article.cs
  4. +49 −0 DiffbotApi/Diffbot.cs
  5. +66 −0 DiffbotApi/DiffbotApi.csproj
  6. +18 −0 DiffbotApi/Frontpage.cs
  7. +22 −0 DiffbotApi/FrontpageInfo.cs
  8. +47 −0 DiffbotApi/FrontpageItem.cs
  9. +198 −0 DiffbotApi/JsonClassHelper.cs
  10. +14 −0 DiffbotApi/Media.cs
  11. +36 −0 DiffbotApi/Properties/AssemblyInfo.cs
  12. BIN DiffbotApi/bin/Debug/DiffbotApi.dll
  13. BIN DiffbotApi/bin/Debug/DiffbotApi.pdb
  14. BIN DiffbotApi/bin/Debug/Newtonsoft.Json.dll
  15. BIN DiffbotApi/bin/Debug/Newtonsoft.Json.pdb
  16. +6,862 −0 DiffbotApi/bin/Debug/Newtonsoft.Json.xml
  17. BIN DiffbotApi/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
  18. +8 −0 DiffbotApi/obj/Debug/DiffbotApi.csproj.FileListAbsolute.txt
  19. BIN DiffbotApi/obj/Debug/DiffbotApi.dll
  20. BIN DiffbotApi/obj/Debug/DiffbotApi.pdb
  21. BIN DiffbotApi/obj/Debug/ResolveAssemblyReference.cache
  22. +4 −0 DiffbotApi/packages.config
  23. +21 −0 README.md
  24. BIN packages/Newtonsoft.Json.4.0.2/Newtonsoft.Json.4.0.2.nupkg
  25. BIN packages/Newtonsoft.Json.4.0.2/lib/net20/Newtonsoft.Json.Net20.dll
  26. BIN packages/Newtonsoft.Json.4.0.2/lib/net20/Newtonsoft.Json.Net20.pdb
  27. +6,520 −0 packages/Newtonsoft.Json.4.0.2/lib/net20/Newtonsoft.Json.Net20.xml
  28. BIN packages/Newtonsoft.Json.4.0.2/lib/net35/Newtonsoft.Json.Net35.dll
  29. BIN packages/Newtonsoft.Json.4.0.2/lib/net35/Newtonsoft.Json.Net35.pdb
  30. +6,711 −0 packages/Newtonsoft.Json.4.0.2/lib/net35/Newtonsoft.Json.Net35.xml
  31. BIN packages/Newtonsoft.Json.4.0.2/lib/net40/Newtonsoft.Json.dll
  32. BIN packages/Newtonsoft.Json.4.0.2/lib/net40/Newtonsoft.Json.pdb
  33. +6,862 −0 packages/Newtonsoft.Json.4.0.2/lib/net40/Newtonsoft.Json.xml
  34. BIN packages/Newtonsoft.Json.4.0.2/lib/sl3-wp/Newtonsoft.Json.WindowsPhone.dll
  35. BIN packages/Newtonsoft.Json.4.0.2/lib/sl3-wp/Newtonsoft.Json.WindowsPhone.pdb
  36. +6,331 −0 packages/Newtonsoft.Json.4.0.2/lib/sl3-wp/Newtonsoft.Json.WindowsPhone.xml
  37. BIN packages/Newtonsoft.Json.4.0.2/lib/sl4/Newtonsoft.Json.Silverlight.dll
  38. BIN packages/Newtonsoft.Json.4.0.2/lib/sl4/Newtonsoft.Json.Silverlight.pdb
  39. +6,361 −0 packages/Newtonsoft.Json.4.0.2/lib/sl4/Newtonsoft.Json.Silverlight.xml
  40. +4 −0 packages/repositories.config
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiffbotApi", "DiffbotApi\DiffbotApi.csproj", "{5AE215E7-1301-47B9-8745-5C5961DD42F8}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {5AE215E7-1301-47B9-8745-5C5961DD42F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5AE215E7-1301-47B9-8745-5C5961DD42F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5AE215E7-1301-47B9-8745-5C5961DD42F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5AE215E7-1301-47B9-8745-5C5961DD42F8}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
Binary file not shown.
@@ -0,0 +1,82 @@
+// JSON C# Class Generator
+// http://at-my-window.blogspot.com/?page=json-class-generator
+
+using System;
+using Newtonsoft.Json.Linq;
+using JsonCSharpClassGenerator;
+
+namespace DiffbotApi
+{
+
+ public class Article
+ {
+
+ public Article(string json)
+ : this(JObject.Parse(json))
+ {
+ }
+
+ private JObject __jobject;
+ public Article(JObject obj)
+ {
+ this.__jobject = obj;
+ }
+
+ public string Author
+ {
+ get
+ {
+ return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "author"));
+ }
+ }
+
+ public string Text
+ {
+ get
+ {
+ return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "text"));
+ }
+ }
+
+ public string Title
+ {
+ get
+ {
+ return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "title"));
+ }
+ }
+
+ public string Date
+ {
+ get
+ {
+ return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "date"));
+ }
+ }
+
+ public string ResolvedUrl
+ {
+ get
+ {
+ return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "resolved_url"));
+ }
+ }
+
+ public string Url
+ {
+ get
+ {
+ return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "url"));
+ }
+ }
+
+ public string Xpath
+ {
+ get
+ {
+ return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "xpath"));
+ }
+ }
+
+ }
+}
@@ -0,0 +1,49 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Net;
+using System.Xml.Serialization;
+using System.IO;
+namespace DiffbotApi
+{
+ public class Diffbot
+ {
+ private const string DIFFBOT_API_URL = "http://www.diffbot.com/api/";
+ private const string ARTICLE_API_SUFFIX = "article";
+ private const string FRONTPAGE_API_SUFFIX = "frontpage";
+ public string DeveloperToken { get; set; }
+
+ public Diffbot(string token)
+ {
+ DeveloperToken = token;
+ }
+
+ public Frontpage Frontpage(string url)
+ {
+ using (WebClient wc = new WebClient())
+ {
+ wc.Proxy = null;
+ string xmlString = wc.DownloadString(getQueryUrl(FRONTPAGE_API_SUFFIX, url));
+ XmlSerializer ser = new XmlSerializer(typeof(Frontpage));
+ return (Frontpage)ser.Deserialize(new StringReader(xmlString));
+ }
+
+ }
+
+ public Article Article(string url)
+ {
+ using (WebClient wc = new WebClient())
+ {
+ wc.Proxy = null;
+ string jsonString = wc.DownloadString(getQueryUrl(ARTICLE_API_SUFFIX, url));
+ return new Article(jsonString);
+ }
+ }
+
+ private string getQueryUrl(string queryType, string url)
+ {
+ return DIFFBOT_API_URL + queryType + "?token=" + DeveloperToken + "&url=" + url;
+ }
+ }
+}
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{5AE215E7-1301-47B9-8745-5C5961DD42F8}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>DiffbotApi</RootNamespace>
+ <AssemblyName>DiffbotApi</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Newtonsoft.Json">
+ <HintPath>..\packages\Newtonsoft.Json.4.0.2\lib\net40\Newtonsoft.Json.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Article.cs" />
+ <Compile Include="Diffbot.cs" />
+ <Compile Include="Frontpage.cs" />
+ <Compile Include="FrontpageInfo.cs" />
+ <Compile Include="FrontpageItem.cs" />
+ <Compile Include="JsonClassHelper.cs" />
+ <Compile Include="Media.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Xml.Serialization;
+
+namespace DiffbotApi
+{
+ [XmlRoot(ElementName="dml")]
+ public class Frontpage
+ {
+ [XmlElement(ElementName="info")]
+ public FrontpageInfo Info { get; set; }
+
+ [XmlElement("item", typeof(FrontpageItem))]
+ public FrontpageItem[] Items { get; set; }
+ }
+}
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Xml.Serialization;
+
+namespace DiffbotApi
+{
+ public class FrontpageInfo
+ {
+ [XmlElement(ElementName="title")]
+ public string Title { get; set; }
+ [XmlElement(ElementName = "sourceType")]
+ public string SourceType { get; set; }
+ [XmlElement(ElementName = "icon")]
+ public string Icon { get; set; }
+ [XmlElement(ElementName = "numItems")]
+ public int NumItems { get; set; }
+ [XmlElement(ElementName = "numSpamItems")]
+ public int NumSpamItems { get; set; }
+ }
+}
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Xml.Serialization;
+namespace DiffbotApi
+{
+ public class FrontpageItem
+ {
+ [XmlAttribute(AttributeName="cluster")]
+ public string Cluster { get; set; }
+
+ [XmlAttribute(AttributeName = "fresh")]
+ public double Freshness { get; set; }
+
+ [XmlAttribute(AttributeName = "id")]
+ public string Id { get; set; }
+
+ [XmlAttribute(AttributeName = "sp")]
+ public double SpamScore { get; set; }
+
+ [XmlAttribute(AttributeName = "sr")]
+ public double StaticRank { get; set; }
+
+ [XmlAttribute(AttributeName = "type")]
+ public string Type { get; set; }
+
+ [XmlAttribute(AttributeName = "xroot")]
+ public string XRoot { get; set; }
+
+ [XmlAttribute(AttributeName = "img")]
+ public string Image { get; set; }
+
+ [XmlElement(ElementName="title")]
+ public string Title { get; set; }
+
+ [XmlElement(ElementName = "link")]
+ public string Link { get; set; }
+
+ [XmlElement(ElementName = "pubDate")]
+ public string PublicationDate { get; set; }
+
+ [XmlElement(ElementName = "description")]
+ public string Description { get; set; }
+
+ }
+}
Oops, something went wrong.

0 comments on commit 1b4ebb8

Please sign in to comment.