Skip to content

Commit 539c726

Browse files
committed
Adding the C# connectors and examples.
1 parent 0d29733 commit 539c726

22 files changed

Lines changed: 1578 additions & 0 deletions
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
2+
Version 0.9.3
3+
4+
Copyright (c) 2011, Majestic-12 Ltd
5+
6+
All rights reserved.
7+
8+
9+
10+
Redistribution and use in source and binary forms, with or without
11+
12+
modification, are permitted provided that the following conditions are met:
13+
14+
* Redistributions of source code must retain the above copyright
15+
16+
notice, this list of conditions and the following disclaimer.
17+
18+
* Redistributions in binary form must reproduce the above copyright
19+
20+
notice, this list of conditions and the following disclaimer in the
21+
22+
documentation and/or other materials provided with the distribution.
23+
24+
* Neither the name of the Majestic-12 Ltd nor the
25+
26+
names of its contributors may be used to endorse or promote products
27+
28+
derived from this software without specific prior written permission.
29+
30+
31+
32+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
33+
34+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
35+
36+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
37+
38+
DISCLAIMED. IN NO EVENT SHALL Majestic-12 Ltd BE LIABLE FOR ANY
39+
40+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
41+
42+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43+
44+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
45+
46+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
47+
48+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
49+
50+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Binary file not shown.
Binary file not shown.
Binary file not shown.
9.5 KB
Binary file not shown.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
2+
Version 0.9.3
3+
4+
Copyright (c) 2011, Majestic-12 Ltd
5+
6+
All rights reserved.
7+
8+
9+
10+
Redistribution and use in source and binary forms, with or without
11+
12+
modification, are permitted provided that the following conditions are met:
13+
14+
* Redistributions of source code must retain the above copyright
15+
16+
notice, this list of conditions and the following disclaimer.
17+
18+
* Redistributions in binary form must reproduce the above copyright
19+
20+
notice, this list of conditions and the following disclaimer in the
21+
22+
documentation and/or other materials provided with the distribution.
23+
24+
* Neither the name of the Majestic-12 Ltd nor the
25+
26+
names of its contributors may be used to endorse or promote products
27+
28+
derived from this software without specific prior written permission.
29+
30+
31+
32+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
33+
34+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
35+
36+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
37+
38+
DISCLAIMED. IN NO EVENT SHALL Majestic-12 Ltd BE LIABLE FOR ANY
39+
40+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
41+
42+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43+
44+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
45+
46+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
47+
48+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
49+
50+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProductVersion>9.0.30729</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{9F9144BF-FAFC-481B-8D6C-0AA9030E49DE}</ProjectGuid>
9+
<OutputType>Exe</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>MajesticSEO.External.RPC.OpenAppSample</RootNamespace>
12+
<AssemblyName>MajesticSEO.External.RPC.OpenAppSample</AssemblyName>
13+
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
14+
<FileAlignment>512</FileAlignment>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<DebugType>pdbonly</DebugType>
27+
<Optimize>true</Optimize>
28+
<OutputPath>bin\Release\</OutputPath>
29+
<DefineConstants>TRACE</DefineConstants>
30+
<ErrorReport>prompt</ErrorReport>
31+
<WarningLevel>4</WarningLevel>
32+
</PropertyGroup>
33+
<ItemGroup>
34+
<Reference Include="System" />
35+
<Reference Include="System.Data" />
36+
<Reference Include="System.Xml" />
37+
</ItemGroup>
38+
<ItemGroup>
39+
<Compile Include="OpenAppGetIndexItemInfo.cs" />
40+
<Compile Include="Properties\AssemblyInfo.cs" />
41+
</ItemGroup>
42+
<ItemGroup>
43+
<ProjectReference Include="..\MajesticSEO.External.RPC\MajesticSEO.External.RPC.csproj">
44+
<Project>{6ED18656-9475-4398-B6B7-929C81B9EFAE}</Project>
45+
<Name>MajesticSEO.External.RPC</Name>
46+
</ProjectReference>
47+
</ItemGroup>
48+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
49+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
50+
Other similar extension points exist, see Microsoft.Common.targets.
51+
<Target Name="BeforeBuild">
52+
</Target>
53+
<Target Name="AfterBuild">
54+
</Target>
55+
-->
56+
</Project>
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text.RegularExpressions;
4+
5+
namespace MajesticSEO.External.RPC.OpenAppSample
6+
{
7+
internal class OpenAppGetIndexItemInfo
8+
{
9+
/// <summary>
10+
///
11+
/// </summary>
12+
/// <param name="args"></param>
13+
private static void Main(string[] args)
14+
{
15+
const string endpoint = "http://enterprise.majesticseo.com/api_command";
16+
17+
Console.WriteLine("\n***********************************************************"
18+
+ "*****************");
19+
20+
Console.WriteLine("\nEndpoint: " + endpoint);
21+
22+
if ("http://enterprise.majesticseo.com/api_command".Equals(endpoint))
23+
{
24+
Console.WriteLine("\nThis program is hard-wired to the Enterprise API.");
25+
26+
Console.WriteLine("\nIf you do not have access to the Enterprise API, "
27+
+ "change the endpoint to: \nhttp://developer.majesticseo.com/api_command.");
28+
}
29+
else
30+
{
31+
Console.WriteLine("\nThis program is hard-wired to the Developer API "
32+
+ "and hence the subset of data \nreturned will be substantially "
33+
+ "smaller than that which will be returned from \neither the "
34+
+ "Enterprise API or the Majestic SEO website.");
35+
36+
Console.WriteLine("\nTo make this program use the Enterprise API, change "
37+
+ "the endpoint to: \nhttp://enterprise.majesticseo.com/api_command.");
38+
}
39+
40+
Console.WriteLine("\n***********************************************************"
41+
+ "*****************");
42+
43+
Console.WriteLine(
44+
"\n\nThis example program will return key information about \"index items\"."
45+
+ "\n\nThe following must be provided in order to run this program: "
46+
+ "\n1. OpenApp \"private key\"\n2. Access Token\n3. List of items to query"
47+
+ "\n\nPlease enter your OpenApp \"private key\":");
48+
49+
string privateKey = Console.ReadLine();
50+
51+
Console.WriteLine("Enter your access token:");
52+
string accessToken = Console.ReadLine();
53+
54+
Console.WriteLine(
55+
"\nPlease enter the list of items you wish to query seperated by "
56+
+ "commas: \n(e.g. majesticseo.com, majestic12.co.uk)");
57+
58+
string itemsToQuery = Console.ReadLine();
59+
string[] items = Regex.Split(itemsToQuery, ", ");
60+
61+
/* create a Dictionary from the resulting array with the key being
62+
* "item0 => first item to query, item1 => second item to query" etc */
63+
Dictionary<string, string> parameters = new Dictionary<string, string>();
64+
for (int i = 0; i < items.Length; i++)
65+
{
66+
parameters.Add("item" + i, items[i]);
67+
}
68+
69+
// add the total number of items to the Dictionary with the key being "items"
70+
parameters.Add("items", items.Length.ToString());
71+
parameters.Add("datasource", "fresh");
72+
73+
APIService apiService = new APIService(privateKey, endpoint);
74+
Response response = apiService.ExecuteOpenAppRequest("GetIndexItemInfo", parameters, accessToken);
75+
76+
// check the response code
77+
if (response.IsOK())
78+
{
79+
// print the results table
80+
DataTable results = response.GetTableForName("Results");
81+
82+
foreach (Dictionary<string, string> row in results.GetTableRows())
83+
{
84+
string item = row["Item"];
85+
Console.WriteLine("\n<" + item + ">");
86+
87+
List<string> keys = new List<string>(row.Keys);
88+
keys.Sort();
89+
90+
foreach (string key in keys)
91+
{
92+
if (!key.Equals("item"))
93+
{
94+
string value = row[key];
95+
Console.WriteLine(" " + key + " ... " + value);
96+
}
97+
}
98+
}
99+
100+
if ("http://developer.majesticseo.com/api_command".Equals(endpoint))
101+
{
102+
Console.WriteLine("\n\n***********************************************************"
103+
+ "*****************");
104+
105+
Console.WriteLine("\nEndpoint: " + endpoint);
106+
107+
Console.WriteLine("\nThis program is hard-wired to the Developer API "
108+
+ "and hence the subset of data \nreturned will be substantially "
109+
+ "smaller than that which will be returned from \neither the "
110+
+ "Enterprise API or the Majestic SEO website.");
111+
112+
Console.WriteLine("\nTo make this program use the Enterprise API, change "
113+
+ "the endpoint to: \nhttp://enterprise.majesticseo.com/api_command.");
114+
115+
Console.WriteLine("\n***********************************************************"
116+
+ "*****************");
117+
}
118+
}
119+
else
120+
{
121+
Console.WriteLine("\nERROR MESSAGE:");
122+
Console.WriteLine(response.GetErrorMessage());
123+
124+
Console.WriteLine("\n\n***********************************************************"
125+
+ "*****************");
126+
127+
Console.WriteLine("\nDebugging Info:");
128+
Console.WriteLine("\n Endpoint: \t" + endpoint);
129+
Console.WriteLine(" OpenApp \"private key\": \t" + privateKey);
130+
Console.WriteLine(" Access Token: \t" + accessToken);
131+
132+
if ("http://enterprise.majesticseo.com/api_command".Equals(endpoint))
133+
{
134+
Console.WriteLine("\n Is this API Key valid for this Endpoint?");
135+
136+
Console.WriteLine("\n This program is hard-wired to the Enterprise API.");
137+
138+
Console.WriteLine("\n If you do not have access to the Enterprise API, "
139+
+ "change the endpoint to: \n http://developer.majesticseo.com/api_command.");
140+
}
141+
142+
Console.WriteLine("\n***********************************************************"
143+
+ "*****************");
144+
}
145+
146+
Console.Read();
147+
}
148+
}
149+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("MajesticSEO.External.RPC.OpenAppSample")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("MajesticSEO.External.RPC.OpenAppSample")]
13+
[assembly: AssemblyCopyright("Copyright © 2011")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("4fea43b2-0d7f-435f-889a-bd17500e4a89")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

0 commit comments

Comments
 (0)