majestic_seo_api 1.3.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +38 -0
- data/.ruby-version +1 -0
- data/Gemfile +3 -5
- data/LICENSE.txt +21 -50
- data/README.markdown +9 -64
- data/Rakefile +4 -85
- data/bin/console +27 -0
- data/bin/setup +8 -0
- data/lib/majestic_seo/api/client.rb +22 -72
- data/lib/majestic_seo/api/item_info.rb +124 -54
- data/lib/majestic_seo/api/item_info_response.rb +7 -45
- data/lib/majestic_seo/api/response.rb +19 -88
- data/lib/majestic_seo/configuration.rb +12 -0
- data/lib/majestic_seo/version.rb +3 -0
- data/lib/majestic_seo_api.rb +32 -13
- data/majestic_seo_api.gemspec +25 -48
- metadata +46 -54
- data/lib/generators/majestic_seo/majestic_seo_generator.rb +0 -18
- data/lib/generators/templates/majestic_seo.template.yml +0 -13
- data/lib/majestic_seo/api/data_table.rb +0 -112
- data/lib/majestic_seo/api/top_back_links_response.rb +0 -44
- data/script/get_index_item_info.rb +0 -137
- data/script/get_top_backlinks.rb +0 -140
- data/script/open_app_get_index_item_info.rb +0 -156
- data/spec/majestic_seo/client_spec.rb +0 -74
- data/spec/majestic_seo/item_info_response_spec.rb +0 -321
- data/spec/majestic_seo/top_back_links_response_spec.rb +0 -31
- data/spec/spec_helper.rb +0 -26
@@ -1,137 +0,0 @@
|
|
1
|
-
|
2
|
-
=begin
|
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
|
-
=end
|
32
|
-
|
33
|
-
# NOTE: The code below is specifically for the GetIndexItemInfo 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
|
-
# add the majestic seo api library to the search path
|
40
|
-
Bundler.require if defined?(Bundler)
|
41
|
-
require File.expand_path('../../lib/majestic_seo_api', __FILE__)
|
42
|
-
|
43
|
-
environment = :production
|
44
|
-
|
45
|
-
puts "\n****************************************************************************"
|
46
|
-
|
47
|
-
puts "\nEnvironment: #{environment}"
|
48
|
-
|
49
|
-
if (environment.eql?(:production))
|
50
|
-
puts "\nThis program is hard-wired to the Enterprise API."
|
51
|
-
|
52
|
-
puts "\nIf you do not have access to the Enterprise API, " +
|
53
|
-
"change the environment to: \n:sandbox."
|
54
|
-
elsif (environment.eql?(:sandbox))
|
55
|
-
puts "\nThis program is hard-wired to the Developer API " +
|
56
|
-
"and hence the subset of data \nreturned will be substantially " +
|
57
|
-
"smaller than that which will be returned from \neither the " +
|
58
|
-
"Enterprise API or the Majestic SEO website."
|
59
|
-
|
60
|
-
puts "\nTo make this program use the Enterprise API, change " +
|
61
|
-
"the environment to: \n:production."
|
62
|
-
end
|
63
|
-
|
64
|
-
puts "\n***********************************************************" +
|
65
|
-
"*****************";
|
66
|
-
|
67
|
-
puts "\n\nThis example program will return key information about \"index items\"." +
|
68
|
-
"\n\nThe following must be provided in order to run this program: " +
|
69
|
-
"\n1. API key \n2. List of items to query" +
|
70
|
-
"\n\nPlease enter your API key:\n"
|
71
|
-
|
72
|
-
api_key = gets.chomp
|
73
|
-
|
74
|
-
puts "\nPlease enter the list of items you wish to query seperated by " +
|
75
|
-
"commas: \n(e.g. majesticseo.com, majestic12.co.uk)\n"
|
76
|
-
|
77
|
-
items_to_query = gets.chomp
|
78
|
-
items = items_to_query.split(/,\s?/)
|
79
|
-
|
80
|
-
client = MajesticSeo::Api::Client.new(api_key, environment)
|
81
|
-
response = client.get_index_item_info(items, {:data_source => :fresh, :timeout => 5})
|
82
|
-
|
83
|
-
if (response && response.success)
|
84
|
-
response.items.each_with_index do |item, index|
|
85
|
-
puts "\n Result: #{index+1}: \n"
|
86
|
-
|
87
|
-
instance_variables = item.instance_variables
|
88
|
-
instance_variables.delete(:@response)
|
89
|
-
instance_variables.delete(:@mappings)
|
90
|
-
|
91
|
-
instance_variables.each do |var|
|
92
|
-
puts " #{var.to_s.gsub("@", "")} ... #{item.instance_variable_get(var)}"
|
93
|
-
end
|
94
|
-
|
95
|
-
puts "\n"
|
96
|
-
end if (response.items && response.items.any?)
|
97
|
-
|
98
|
-
if (environment.eql?(:sandbox))
|
99
|
-
puts "\n\n***********************************************************" +
|
100
|
-
"*****************"
|
101
|
-
|
102
|
-
puts "\nEnvironment: #{environment}"
|
103
|
-
|
104
|
-
puts"\nThis program is hard-wired to the Developer API " +
|
105
|
-
"and hence the subset of data \nreturned will be substantially " +
|
106
|
-
"smaller than that which will be returned from \neither the " +
|
107
|
-
"Enterprise API or the Majestic SEO website."
|
108
|
-
|
109
|
-
puts "\nTo make this program use the Enterprise API, change " +
|
110
|
-
"the environment to: \n:production."
|
111
|
-
|
112
|
-
puts "\n***********************************************************" +
|
113
|
-
"*****************"
|
114
|
-
end
|
115
|
-
|
116
|
-
else
|
117
|
-
puts "\nERROR MESSAGE:"
|
118
|
-
puts response.error_message
|
119
|
-
|
120
|
-
puts "\n\n***********************************************************" +
|
121
|
-
"*****************"
|
122
|
-
|
123
|
-
puts "\nDebugging Info:"
|
124
|
-
puts "\n Environment: \t#{environment}"
|
125
|
-
puts " API Key: \t#{api_key}"
|
126
|
-
|
127
|
-
if(environment.eql?(:production))
|
128
|
-
puts "\n Is this API Key valid for this Endpoint?"
|
129
|
-
|
130
|
-
puts "\n This program is hard-wired to the Enterprise API."
|
131
|
-
|
132
|
-
puts "\n If you do not have access to the Enterprise API, " +
|
133
|
-
"change the environment to: \n :sandbox."
|
134
|
-
end
|
135
|
-
|
136
|
-
puts "\n****************************************************************************"
|
137
|
-
end
|
data/script/get_top_backlinks.rb
DELETED
@@ -1,140 +0,0 @@
|
|
1
|
-
|
2
|
-
=begin
|
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
|
-
=end
|
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
|
-
# add the majesticseo-external-rpc library to the search path
|
40
|
-
$: << File.expand_path(File.dirname(__FILE__));
|
41
|
-
|
42
|
-
require 'majesticseo-external-rpc/api_service'
|
43
|
-
|
44
|
-
endpoint = "http://enterprise.majesticseo.com/api_command";
|
45
|
-
|
46
|
-
puts "\n***********************************************************" +
|
47
|
-
"*****************";
|
48
|
-
|
49
|
-
puts "\nEndpoint: #{endpoint}";
|
50
|
-
|
51
|
-
if("http://enterprise.majesticseo.com/api_command" == endpoint)
|
52
|
-
puts "\nThis program is hard-wired to the Enterprise API.";
|
53
|
-
|
54
|
-
puts "\nIf you do not have access to the Enterprise API, " +
|
55
|
-
"change the endpoint to: \nhttp://developer.majesticseo.com/api_command.";
|
56
|
-
else
|
57
|
-
puts "\nThis program is hard-wired to the Developer API " +
|
58
|
-
"and hence the subset of data \nreturned will be substantially " +
|
59
|
-
"smaller than that which will be returned from \neither the " +
|
60
|
-
"Enterprise API or the Majestic SEO website.";
|
61
|
-
|
62
|
-
puts "\nTo make this program use the Enterprise API, change " +
|
63
|
-
"the endpoint to: \nhttp://enterprise.majesticseo.com/api_command.";
|
64
|
-
end
|
65
|
-
|
66
|
-
puts "\n***********************************************************" +
|
67
|
-
"*****************";
|
68
|
-
|
69
|
-
puts "\n\nThis example program will return the top backlinks for any URL, domain " +
|
70
|
-
"\nor subdomain." +
|
71
|
-
"\n\nThe following must be provided in order to run this program: " +
|
72
|
-
"\n1. API key, \n2. A URL, domain or subdomain to query" +
|
73
|
-
"\n\nPlease enter your API key:\n";
|
74
|
-
|
75
|
-
api_key = gets.chomp;
|
76
|
-
|
77
|
-
puts "\nPlease enter a URL, domain or subdomain to query:\n";
|
78
|
-
|
79
|
-
item_to_query = gets.chomp;
|
80
|
-
|
81
|
-
# set up parameters
|
82
|
-
parameters = Hash.new;
|
83
|
-
parameters["MaxSourceURLs"] = "10";
|
84
|
-
parameters["URL"] = item_to_query;
|
85
|
-
parameters["GetUrlData"] = "1";
|
86
|
-
parameters["MaxSourceURLsPerRefDomain"] = "1";
|
87
|
-
parameters["datasource"] = "fresh";
|
88
|
-
|
89
|
-
api_service = ApiService.new(api_key, endpoint);
|
90
|
-
response = api_service.execute_command('GetTopBackLinks', parameters);
|
91
|
-
|
92
|
-
# check the response code
|
93
|
-
if(response.is_ok)
|
94
|
-
# print the URL table
|
95
|
-
results = response.table_for_name('URL');
|
96
|
-
results.rows.each do |row|
|
97
|
-
puts "\nURL: " + row['SourceURL']
|
98
|
-
puts "ACRank: " + row['ACRank']
|
99
|
-
end
|
100
|
-
|
101
|
-
if("http://developer.majesticseo.com/api_command" == endpoint)
|
102
|
-
puts "\n\n***********************************************************" +
|
103
|
-
"*****************";
|
104
|
-
|
105
|
-
puts "\nEndpoint: #{endpoint}";
|
106
|
-
|
107
|
-
puts"\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
|
-
puts "\nTo make this program use the Enterprise API, change " +
|
113
|
-
"the endpoint to: \nhttp://enterprise.majesticseo.com/api_command.";
|
114
|
-
|
115
|
-
puts "\n***********************************************************" +
|
116
|
-
"*****************";
|
117
|
-
end
|
118
|
-
else
|
119
|
-
puts "\nERROR MESSAGE:";
|
120
|
-
puts response.error_message;
|
121
|
-
|
122
|
-
puts "\n\n***********************************************************" +
|
123
|
-
"*****************";
|
124
|
-
|
125
|
-
puts "\nDebugging Info:";
|
126
|
-
puts "\n Endpoint: \t#{endpoint}";
|
127
|
-
puts " API Key: \t#{api_key}";
|
128
|
-
|
129
|
-
if("http://enterprise.majesticseo.com/api_command" == endpoint)
|
130
|
-
puts "\n Is this API Key valid for this Endpoint?";
|
131
|
-
|
132
|
-
puts "\n This program is hard-wired to the Enterprise API.";
|
133
|
-
|
134
|
-
puts "\n If you do not have access to the Enterprise API, " +
|
135
|
-
"change the endpoint to: \n http://developer.majesticseo.com/api_command.";
|
136
|
-
end
|
137
|
-
|
138
|
-
puts "\n***********************************************************" +
|
139
|
-
"*****************";
|
140
|
-
end
|
@@ -1,156 +0,0 @@
|
|
1
|
-
|
2
|
-
=begin
|
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
|
-
=end
|
32
|
-
|
33
|
-
# NOTE: The code below is specifically for the GetIndexItemInfo 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
|
-
# add the majesticseo-external-rpc library to the search path
|
40
|
-
$: << File.expand_path(File.dirname(__FILE__));
|
41
|
-
|
42
|
-
require 'majesticseo-external-rpc/api_service'
|
43
|
-
|
44
|
-
endpoint = "http://enterprise.majesticseo.com/api_command";
|
45
|
-
|
46
|
-
puts "\n***********************************************************" +
|
47
|
-
"*****************";
|
48
|
-
|
49
|
-
puts "\nEndpoint: #{endpoint}";
|
50
|
-
|
51
|
-
if("http://enterprise.majesticseo.com/api_command" == endpoint)
|
52
|
-
puts "\nThis program is hard-wired to the Enterprise API.";
|
53
|
-
|
54
|
-
puts "\nIf you do not have access to the Enterprise API, " +
|
55
|
-
"change the endpoint to: \nhttp://developer.majesticseo.com/api_command.";
|
56
|
-
else
|
57
|
-
puts "\nThis program is hard-wired to the Developer API " +
|
58
|
-
"and hence the subset of data \nreturned will be substantially " +
|
59
|
-
"smaller than that which will be returned from \neither the " +
|
60
|
-
"Enterprise API or the Majestic SEO website.";
|
61
|
-
|
62
|
-
puts "\nTo make this program use the Enterprise API, change " +
|
63
|
-
"the endpoint to: \nhttp://enterprise.majesticseo.com/api_command.";
|
64
|
-
end
|
65
|
-
|
66
|
-
puts "\n***********************************************************" +
|
67
|
-
"*****************";
|
68
|
-
|
69
|
-
puts "\n\nThis example program will return key information about \"index items\"." +
|
70
|
-
"\n\nThe following must be provided in order to run this program: " +
|
71
|
-
"\n1. OpenApp \"private key\"\n2. Access Token\n3. List of items to query" +
|
72
|
-
"\n\nPlease enter a valid OpenApp \"private key\":\n";
|
73
|
-
|
74
|
-
private_key = gets.chomp;
|
75
|
-
|
76
|
-
puts "\nEnter your user access token:\n";
|
77
|
-
|
78
|
-
access_token = gets.chomp;
|
79
|
-
|
80
|
-
puts "\nPlease enter the list of items you wish to query seperated by " +
|
81
|
-
"commas: \n(e.g. majesticseo.com, majestic12.co.uk)\n";
|
82
|
-
|
83
|
-
items_to_query = gets.chomp;
|
84
|
-
items = items_to_query.split(/, /);
|
85
|
-
|
86
|
-
# create a hash from the resulting array with the key being
|
87
|
-
# "item0 => first item to query, item1 => second item to query" etc
|
88
|
-
items_hash = Hash.new;
|
89
|
-
0.upto(items.length-1) do |i|
|
90
|
-
items_hash["item" + i.to_s] = items[i];
|
91
|
-
end
|
92
|
-
|
93
|
-
# add the total number of items to the hash with the key being "items"
|
94
|
-
items_hash['items'] = items.length.to_s;
|
95
|
-
items_hash['datasource'] = 'fresh';
|
96
|
-
|
97
|
-
api_service = ApiService.new(private_key, endpoint);
|
98
|
-
response = api_service.execute_openapp_request('GetIndexItemInfo', items_hash, access_token);
|
99
|
-
|
100
|
-
# check the response code
|
101
|
-
if(response.is_ok)
|
102
|
-
# print the results table
|
103
|
-
results = response.table_for_name('Results');
|
104
|
-
results.rows.each do |row|
|
105
|
-
item = row['Item'];
|
106
|
-
puts "\n<#{item}>\n";
|
107
|
-
|
108
|
-
row.keys.sort.each do |key|
|
109
|
-
unless(key.eql?('Item'))
|
110
|
-
value = row[key];
|
111
|
-
puts " #{key} ... #{value}\n";
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
if("http://developer.majesticseo.com/api_command" == endpoint)
|
117
|
-
puts "\n\n***********************************************************" +
|
118
|
-
"*****************";
|
119
|
-
|
120
|
-
puts "\nEndpoint: #{endpoint}";
|
121
|
-
|
122
|
-
puts"\nThis program is hard-wired to the Developer API " +
|
123
|
-
"and hence the subset of data \nreturned will be substantially " +
|
124
|
-
"smaller than that which will be returned from \neither the " +
|
125
|
-
"Enterprise API or the Majestic SEO website.";
|
126
|
-
|
127
|
-
puts "\nTo make this program use the Enterprise API, change " +
|
128
|
-
"the endpoint to: \nhttp://enterprise.majesticseo.com/api_command.";
|
129
|
-
|
130
|
-
puts "\n***********************************************************" +
|
131
|
-
"*****************";
|
132
|
-
end
|
133
|
-
else
|
134
|
-
puts "\nERROR MESSAGE:";
|
135
|
-
puts response.error_message;
|
136
|
-
|
137
|
-
puts "\n\n***********************************************************" +
|
138
|
-
"*****************";
|
139
|
-
|
140
|
-
puts "\nDebugging Info:\n";
|
141
|
-
puts "Endpoint:\t#{endpoint}\n";
|
142
|
-
puts "OpenApp \"private key\":\t#{private_key}\n";
|
143
|
-
puts "Access token:\t#{access_token}\n";
|
144
|
-
|
145
|
-
if("http://enterprise.majesticseo.com/api_command" == endpoint)
|
146
|
-
puts "\n Is this API Key valid for this Endpoint?";
|
147
|
-
|
148
|
-
puts "\n This program is hard-wired to the Enterprise API.";
|
149
|
-
|
150
|
-
puts "\n If you do not have access to the Enterprise API, " +
|
151
|
-
"change the endpoint to: \n http://developer.majesticseo.com/api_command.";
|
152
|
-
end
|
153
|
-
|
154
|
-
puts "\n***********************************************************" +
|
155
|
-
"*****************";
|
156
|
-
end
|
@@ -1,74 +0,0 @@
|
|
1
|
-
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
-
|
3
|
-
describe "Majestic Seo Api Client" do
|
4
|
-
describe "initialization settings" do
|
5
|
-
|
6
|
-
describe "with defaults" do
|
7
|
-
before(:each) do
|
8
|
-
config = {"environment" => "sandbox", "api_key" => "api_key"}
|
9
|
-
MajesticSeo::Api::Client.any_instance.expects(:config).at_least_once.returns(config)
|
10
|
-
@client = MajesticSeo::Api::Client.new
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should contain a key" do
|
14
|
-
@client.api_key.should == "api_key"
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should have the environment set to sandbox" do
|
18
|
-
@client.environment.should == :sandbox
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "#get_index_item_info" do
|
24
|
-
it "should send a correct request" do
|
25
|
-
client = MajesticSeo::Api::Client.new
|
26
|
-
|
27
|
-
urls = ["google.com", "yahoo.com"]
|
28
|
-
parameters = {:data_source => :historic}
|
29
|
-
options = {:timeout => 5}
|
30
|
-
|
31
|
-
expecting = {"datasource" => :historic,
|
32
|
-
"items" => 2,
|
33
|
-
"item0" => "google.com",
|
34
|
-
"item1" => "yahoo.com",
|
35
|
-
"app_api_key" => client.api_key,
|
36
|
-
"cmd" => "GetIndexItemInfo"
|
37
|
-
}
|
38
|
-
|
39
|
-
client.expects(:execute_request).with(expecting, options)
|
40
|
-
response = client.get_index_item_info(urls, parameters, options)
|
41
|
-
|
42
|
-
#To test behind a proxy:
|
43
|
-
#response = client.get_index_item_info(urls, parameters, options.merge(:proxy => {:uri => URI('http://proxy.com:1234')}))
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe "#get_top_back_links" do
|
48
|
-
it "should send a correct request" do
|
49
|
-
client = MajesticSeo::Api::Client.new
|
50
|
-
|
51
|
-
url = "google.com"
|
52
|
-
parameters = {:data_source => :historic}
|
53
|
-
options = {:timeout => 5}
|
54
|
-
|
55
|
-
expecting = {"datasource" => :historic,
|
56
|
-
"URL" => "google.com",
|
57
|
-
"MaxSourceURLs" => 100,
|
58
|
-
"ShowDomainInfo" => 0,
|
59
|
-
"GetUrlData" => 1,
|
60
|
-
"GetSubDomainData" => 0,
|
61
|
-
"GetRootDomainData" => 0,
|
62
|
-
"MaxSourceURLsPerRefDomain" => -1,
|
63
|
-
"DebugForceQueue" => 0,
|
64
|
-
"app_api_key" => client.api_key,
|
65
|
-
"cmd" => "GetTopBackLinks"}
|
66
|
-
|
67
|
-
client.expects(:execute_request).with(expecting, options)
|
68
|
-
response = client.get_top_back_links(url, parameters, options)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|