Skip to content

Commit e91c91d

Browse files
committed
Fixed a possible response parsing bug
1 parent 539c726 commit e91c91d

15 files changed

Lines changed: 235 additions & 173 deletions

File tree

LICENSE

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Copyright (c) 2015, Majestic.com
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
7+
* Redistributions of source code must retain the above copyright notice, this
8+
list of conditions and the following disclaimer.
9+
10+
* Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the documentation
12+
and/or other materials provided with the distribution.
13+
14+
* Neither the name of Csharp-API-Connector nor the names of its
15+
contributors may be used to endorse or promote products derived from
16+
this software without specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Csharp-API-Connector
22
====================
33

4-
The C# connector is written using .NET Framework 3.5 and Visual Studio 2008.
4+
The C# connector is written using .NET Framework 3.5 and Visual Studio 2008.
Binary file not shown.
Binary file not shown.
Binary file not shown.
512 Bytes
Binary file not shown.
48.5 KB
Binary file not shown.

majesticseo_external_rpc/MajesticSEO.External.RPC.OpenAppSample/MajesticSEO.External.RPC.OpenAppSample.csproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
44
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
55
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -12,6 +12,11 @@
1212
<AssemblyName>MajesticSEO.External.RPC.OpenAppSample</AssemblyName>
1313
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
1414
<FileAlignment>512</FileAlignment>
15+
<FileUpgradeFlags>
16+
</FileUpgradeFlags>
17+
<UpgradeBackupLocation>
18+
</UpgradeBackupLocation>
19+
<OldToolsVersion>3.5</OldToolsVersion>
1520
</PropertyGroup>
1621
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1722
<DebugSymbols>true</DebugSymbols>

majesticseo_external_rpc/MajesticSEO.External.RPC.Sample1/MajesticSEO.External.RPC.Sample1.csproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
44
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
55
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -13,6 +13,11 @@
1313
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
1414
<FileAlignment>512</FileAlignment>
1515
<StartupObject>MajesticSEO.External.RPC.GetIndexItemInfo</StartupObject>
16+
<FileUpgradeFlags>
17+
</FileUpgradeFlags>
18+
<UpgradeBackupLocation>
19+
</UpgradeBackupLocation>
20+
<OldToolsVersion>3.5</OldToolsVersion>
1621
</PropertyGroup>
1722
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1823
<DebugSymbols>true</DebugSymbols>

majesticseo_external_rpc/MajesticSEO.External.RPC.Sample2/GetBackLinkData.cs renamed to majesticseo_external_rpc/MajesticSEO.External.RPC.Sample2/GetTopBackLinks.cs

Lines changed: 162 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -1,161 +1,162 @@
1-

2-
/// <copyright>
3-
///
4-
/// Version 0.9.3
5-
///
6-
/// Copyright (c) 2011, Majestic-12 Ltd
7-
/// All rights reserved.
8-
///
9-
/// Redistribution and use in source and binary forms, with or without
10-
/// modification, are permitted provided that the following conditions are met:
11-
/// 1. Redistributions of source code must retain the above copyright
12-
/// notice, this list of conditions and the following disclaimer.
13-
/// 2. Redistributions in binary form must reproduce the above copyright
14-
/// notice, this list of conditions and the following disclaimer in the
15-
/// documentation and/or other materials provided with the distribution.
16-
/// 3. Neither the name of the Majestic-12 Ltd nor the
17-
/// names of its contributors may be used to endorse or promote products
18-
/// derived from this software without specific prior written permission.
19-
///
20-
/// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21-
/// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22-
/// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23-
/// DISCLAIMED. IN NO EVENT SHALL Majestic-12 Ltd BE LIABLE FOR ANY
24-
/// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25-
/// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26-
/// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27-
/// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28-
/// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29-
/// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30-
///
31-
/// </copyright>
32-
33-
/* NOTE: The code below is specifically for the GetTopbackLinks API command
34-
* For other API commands, the arguments required may differ.
35-
* Please refer to the Majestic SEO Developer Wiki for more information
36-
* regarding other API commands and their arguments.
37-
*/
38-
39-
using System;
40-
using System.Collections.Generic;
41-
using System.Text.RegularExpressions;
42-
43-
namespace MajesticSEO.External.RPC
44-
{
45-
public class GetBackLinkData
46-
{
47-
public static void Main(string[] args)
48-
{
49-
string endpoint = "http://enterprise.majesticseo.com/api_command";
50-
51-
Console.WriteLine("\n***********************************************************"
52-
+ "*****************");
53-
54-
Console.WriteLine("\nEndpoint: " + endpoint);
55-
56-
if ("http://enterprise.majesticseo.com/api_command".Equals(endpoint))
57-
{
58-
Console.WriteLine("\nThis program is hard-wired to the Enterprise API.");
59-
60-
Console.WriteLine("\nIf you do not have access to the Enterprise API, "
61-
+ "change the endpoint to: \nhttp://developer.majesticseo.com/api_command.");
62-
}
63-
else
64-
{
65-
Console.WriteLine("\nThis program is hard-wired to the Developer API "
66-
+ "and hence the subset of data \nreturned will be substantially "
67-
+ "smaller than that which will be returned from \neither the "
68-
+ "Enterprise API or the Majestic SEO website.");
69-
70-
Console.WriteLine("\nTo make this program use the Enterprise API, change "
71-
+ "the endpoint to: \nhttp://enterprise.majesticseo.com/api_command.");
72-
}
73-
74-
Console.WriteLine("\n***********************************************************"
75-
+ "*****************");
76-
77-
Console.WriteLine(
78-
"\n\nThis example program will return the top backlinks for any URL, domain "
79-
+ "\nor subdomain."
80-
+ "\n\nThe following must be provided in order to run this program: "
81-
+ "\n1. API key "
82-
+ "\n2. A URL, domain or subdomain to query"
83-
+ "\n\nPlease enter your API key:");
84-
85-
string app_api_key = Console.ReadLine();
86-
87-
Console.WriteLine("\nPlease enter a URL, domain or subdomain to query:");
88-
89-
string itemToQuery = Console.ReadLine();
90-
91-
// set up parameters
92-
Dictionary<string, string> parameters = new Dictionary<string, string>();
93-
parameters.Add("datasource", "fresh");
94-
parameters.Add("Count", "10");
95-
parameters.Add("item", itemToQuery);
96-
parameters.Add("Mode", "0");
97-
98-
APIService apiService = new APIService(app_api_key, endpoint);
99-
Response response = apiService.ExecuteCommand("GetBackLinkData", parameters);
100-
101-
// check the response code
102-
if(response.IsOK())
103-
{
104-
// print the URL table
105-
DataTable results = response.GetTableForName("BackLinks");
106-
107-
foreach(Dictionary<string, string> row in results.GetTableRows())
108-
{
109-
Console.WriteLine("\nURL: " + row["SourceURL"]);
110-
Console.WriteLine("ACRank: " + row["ACRank"]);
111-
}
112-
113-
if ("http://developer.majesticseo.com/api_command".Equals(endpoint))
114-
{
115-
Console.WriteLine("\n\n***********************************************************"
116-
+ "*****************");
117-
118-
Console.WriteLine("\nEndpoint: " + endpoint);
119-
120-
Console.WriteLine("\nThis program is hard-wired to the Developer API "
121-
+ "and hence the subset of data \nreturned will be substantially "
122-
+ "smaller than that which will be returned from \neither the "
123-
+ "Enterprise API or the Majestic SEO website.");
124-
125-
Console.WriteLine("\nTo make this program use the Enterprise API, change "
126-
+ "the endpoint to: \nhttp://enterprise.majesticseo.com/api_command.");
127-
128-
Console.WriteLine("\n***********************************************************"
129-
+ "*****************");
130-
}
131-
}
132-
else
133-
{
134-
Console.WriteLine("\nERROR MESSAGE:");
135-
Console.WriteLine(response.GetErrorMessage());
136-
137-
Console.WriteLine("\n\n***********************************************************"
138-
+ "*****************");
139-
140-
Console.WriteLine("\nDebugging Info:");
141-
Console.WriteLine("\n Endpoint: \t" + endpoint);
142-
Console.WriteLine(" API Key: \t" + app_api_key);
143-
144-
if ("http://enterprise.majesticseo.com/api_command".Equals(endpoint))
145-
{
146-
Console.WriteLine("\n Is this API Key valid for this Endpoint?");
147-
148-
Console.WriteLine("\n This program is hard-wired to the Enterprise API.");
149-
150-
Console.WriteLine("\n If you do not have access to the Enterprise API, "
151-
+ "change the endpoint to: \n http://developer.majesticseo.com/api_command.");
152-
}
153-
154-
Console.WriteLine("\n***********************************************************"
155-
+ "*****************");
156-
}
157-
158-
Console.Read();
159-
}
160-
}
161-
}
1+

2+
/// <copyright>
3+
///
4+
/// Version 0.9.3
5+
///
6+
/// Copyright (c) 2011, Majestic-12 Ltd
7+
/// All rights reserved.
8+
///
9+
/// Redistribution and use in source and binary forms, with or without
10+
/// modification, are permitted provided that the following conditions are met:
11+
/// 1. Redistributions of source code must retain the above copyright
12+
/// notice, this list of conditions and the following disclaimer.
13+
/// 2. Redistributions in binary form must reproduce the above copyright
14+
/// notice, this list of conditions and the following disclaimer in the
15+
/// documentation and/or other materials provided with the distribution.
16+
/// 3. Neither the name of the Majestic-12 Ltd nor the
17+
/// names of its contributors may be used to endorse or promote products
18+
/// derived from this software without specific prior written permission.
19+
///
20+
/// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21+
/// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22+
/// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
/// DISCLAIMED. IN NO EVENT SHALL Majestic-12 Ltd BE LIABLE FOR ANY
24+
/// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25+
/// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26+
/// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27+
/// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+
/// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29+
/// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
///
31+
/// </copyright>
32+
33+
/* NOTE: The code below is specifically for the GetTopbackLinks API command
34+
* For other API commands, the arguments required may differ.
35+
* Please refer to the Majestic SEO Developer Wiki for more information
36+
* regarding other API commands and their arguments.
37+
*/
38+
39+
using System;
40+
using System.Collections.Generic;
41+
using System.Text.RegularExpressions;
42+
43+
namespace MajesticSEO.External.RPC
44+
{
45+
public class GetTopBackLinks
46+
{
47+
public static void Main(string[] args)
48+
{
49+
string endpoint = "http://enterprise.majesticseo.com/api_command";
50+
51+
Console.WriteLine("\n***********************************************************"
52+
+ "*****************");
53+
54+
Console.WriteLine("\nEndpoint: " + endpoint);
55+
56+
if ("http://enterprise.majesticseo.com/api_command".Equals(endpoint))
57+
{
58+
Console.WriteLine("\nThis program is hard-wired to the Enterprise API.");
59+
60+
Console.WriteLine("\nIf you do not have access to the Enterprise API, "
61+
+ "change the endpoint to: \nhttp://developer.majesticseo.com/api_command.");
62+
}
63+
else
64+
{
65+
Console.WriteLine("\nThis program is hard-wired to the Developer API "
66+
+ "and hence the subset of data \nreturned will be substantially "
67+
+ "smaller than that which will be returned from \neither the "
68+
+ "Enterprise API or the Majestic SEO website.");
69+
70+
Console.WriteLine("\nTo make this program use the Enterprise API, change "
71+
+ "the endpoint to: \nhttp://enterprise.majesticseo.com/api_command.");
72+
}
73+
74+
Console.WriteLine("\n***********************************************************"
75+
+ "*****************");
76+
77+
Console.WriteLine(
78+
"\n\nThis example program will return the top backlinks for any URL, domain "
79+
+ "\nor subdomain."
80+
+ "\n\nThe following must be provided in order to run this program: "
81+
+ "\n1. API key "
82+
+ "\n2. A URL, domain or subdomain to query"
83+
+ "\n\nPlease enter your API key:");
84+
85+
string app_api_key = Console.ReadLine();
86+
87+
Console.WriteLine("\nPlease enter a URL, domain or subdomain to query:");
88+
89+
string itemToQuery = Console.ReadLine();
90+
91+
// set up parameters
92+
Dictionary<string, string> parameters = new Dictionary<string, string>();
93+
parameters.Add("datasource", "fresh");
94+
parameters.Add("MaxSourceURLs", "10");
95+
parameters.Add("URL", itemToQuery);
96+
parameters.Add("GetUrlData", "1");
97+
parameters.Add("MaxSourceURLsPerRefDomain", "1");
98+
99+
APIService apiService = new APIService(app_api_key, endpoint);
100+
Response response = apiService.ExecuteCommand("GetTopBackLinks", parameters);
101+
102+
// check the response code
103+
if(response.IsOK())
104+
{
105+
// print the URL table
106+
DataTable results = response.GetTableForName("URL");
107+
108+
foreach(Dictionary<string, string> row in results.GetTableRows())
109+
{
110+
Console.WriteLine("\nURL: " + row["SourceURL"]);
111+
Console.WriteLine("ACRank: " + row["ACRank"]);
112+
}
113+
114+
if ("http://developer.majesticseo.com/api_command".Equals(endpoint))
115+
{
116+
Console.WriteLine("\n\n***********************************************************"
117+
+ "*****************");
118+
119+
Console.WriteLine("\nEndpoint: " + endpoint);
120+
121+
Console.WriteLine("\nThis program is hard-wired to the Developer API "
122+
+ "and hence the subset of data \nreturned will be substantially "
123+
+ "smaller than that which will be returned from \neither the "
124+
+ "Enterprise API or the Majestic SEO website.");
125+
126+
Console.WriteLine("\nTo make this program use the Enterprise API, change "
127+
+ "the endpoint to: \nhttp://enterprise.majesticseo.com/api_command.");
128+
129+
Console.WriteLine("\n***********************************************************"
130+
+ "*****************");
131+
}
132+
}
133+
else
134+
{
135+
Console.WriteLine("\nERROR MESSAGE:");
136+
Console.WriteLine(response.GetErrorMessage());
137+
138+
Console.WriteLine("\n\n***********************************************************"
139+
+ "*****************");
140+
141+
Console.WriteLine("\nDebugging Info:");
142+
Console.WriteLine("\n Endpoint: \t" + endpoint);
143+
Console.WriteLine(" API Key: \t" + app_api_key);
144+
145+
if ("http://enterprise.majesticseo.com/api_command".Equals(endpoint))
146+
{
147+
Console.WriteLine("\n Is this API Key valid for this Endpoint?");
148+
149+
Console.WriteLine("\n This program is hard-wired to the Enterprise API.");
150+
151+
Console.WriteLine("\n If you do not have access to the Enterprise API, "
152+
+ "change the endpoint to: \n http://developer.majesticseo.com/api_command.");
153+
}
154+
155+
Console.WriteLine("\n***********************************************************"
156+
+ "*****************");
157+
}
158+
159+
Console.Read();
160+
}
161+
}
162+
}

0 commit comments

Comments
 (0)