|
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