httr POST with keywordtool.io
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm struggling to get httr to work with an API that my company is currently using and for the life of me I can't work out why.
x <- c("Electronic cigarette",
"Cloud-chasing electronic cigarette",
"Safety of electronic cigarettes",
"Electronic cigarette aerosol and liquid",
"Openvape",
"Blu eCigs",
"Regulation of electronic cigarettes",
"PAX Labs",
"Construction of electronic cigarettes",
"Vape shop",
"Hon Lik",
"Dragonite International Limited",
"Positions of medical organizations on electronic cigarettes",
"Evolv",
"List of vaping bans in the United States",
"VMR Products",
"List of electronic cigarette brands",
"Electronic cigarettes in Australia",
"LOGIC electronic cigarette",
"VUSE electronic cigarette",
"NJOY",
"R. J. Reynolds Vapor Company",
"MarkTen",
"Vista Vapors",
"Riccardo Polosa",
"Ten Motives",
)
vars <- list(
keyword = as.character(x),
apikey = "apikeyhere",
metrics_location = "2826",
metrics_language = "en",
metrics_network = "googlesearchnetwork",
metrics_currency = "USD",
output = "json"
)
res <- POST("https://api.keywordtool.io/v2/search/volume/google"
, body = vars
, encode = "json", verbose())
when I do this for different metrics locations (e.g., 2826 is the UK), it just returns the data for the US which is the default. Is seems to be reading the data in the keyword portion of the list, but then ignoring the rest. The documentation for the API can be found here (unfortunatley the API is paid): https://keywordtool.io/api/documentation#examples
I'm able to get different results for the US and the UK when I format as a php script and run via the terminal, I just don't seem to be able to get it to work with httr. Ideas would be welcome.
edit:
two of the parameters needed to have their values in a list, even if for just one item. poor comprehension on my part.
r post httr
add a comment |
I'm struggling to get httr to work with an API that my company is currently using and for the life of me I can't work out why.
x <- c("Electronic cigarette",
"Cloud-chasing electronic cigarette",
"Safety of electronic cigarettes",
"Electronic cigarette aerosol and liquid",
"Openvape",
"Blu eCigs",
"Regulation of electronic cigarettes",
"PAX Labs",
"Construction of electronic cigarettes",
"Vape shop",
"Hon Lik",
"Dragonite International Limited",
"Positions of medical organizations on electronic cigarettes",
"Evolv",
"List of vaping bans in the United States",
"VMR Products",
"List of electronic cigarette brands",
"Electronic cigarettes in Australia",
"LOGIC electronic cigarette",
"VUSE electronic cigarette",
"NJOY",
"R. J. Reynolds Vapor Company",
"MarkTen",
"Vista Vapors",
"Riccardo Polosa",
"Ten Motives",
)
vars <- list(
keyword = as.character(x),
apikey = "apikeyhere",
metrics_location = "2826",
metrics_language = "en",
metrics_network = "googlesearchnetwork",
metrics_currency = "USD",
output = "json"
)
res <- POST("https://api.keywordtool.io/v2/search/volume/google"
, body = vars
, encode = "json", verbose())
when I do this for different metrics locations (e.g., 2826 is the UK), it just returns the data for the US which is the default. Is seems to be reading the data in the keyword portion of the list, but then ignoring the rest. The documentation for the API can be found here (unfortunatley the API is paid): https://keywordtool.io/api/documentation#examples
I'm able to get different results for the US and the UK when I format as a php script and run via the terminal, I just don't seem to be able to get it to work with httr. Ideas would be welcome.
edit:
two of the parameters needed to have their values in a list, even if for just one item. poor comprehension on my part.
r post httr
If you can get it to work with php, try posting to a site like requestb.in where you can see what's actually being sent to the server. Then compare that to what you get when you usehttr
to do the same. There is likely some difference in the requests you are sending.
– MrFlick
Feb 6 '18 at 19:12
thanks @MrFlick, good suggestion. I've uploaded the output to imgur: imgur.com/a/T6rkc the output nearest the top is a php script, the lower is httr. The headers are different, but not in a way that seems relevant to the differing output, as far as I can tell.
– user1200
Feb 7 '18 at 8:23
add a comment |
I'm struggling to get httr to work with an API that my company is currently using and for the life of me I can't work out why.
x <- c("Electronic cigarette",
"Cloud-chasing electronic cigarette",
"Safety of electronic cigarettes",
"Electronic cigarette aerosol and liquid",
"Openvape",
"Blu eCigs",
"Regulation of electronic cigarettes",
"PAX Labs",
"Construction of electronic cigarettes",
"Vape shop",
"Hon Lik",
"Dragonite International Limited",
"Positions of medical organizations on electronic cigarettes",
"Evolv",
"List of vaping bans in the United States",
"VMR Products",
"List of electronic cigarette brands",
"Electronic cigarettes in Australia",
"LOGIC electronic cigarette",
"VUSE electronic cigarette",
"NJOY",
"R. J. Reynolds Vapor Company",
"MarkTen",
"Vista Vapors",
"Riccardo Polosa",
"Ten Motives",
)
vars <- list(
keyword = as.character(x),
apikey = "apikeyhere",
metrics_location = "2826",
metrics_language = "en",
metrics_network = "googlesearchnetwork",
metrics_currency = "USD",
output = "json"
)
res <- POST("https://api.keywordtool.io/v2/search/volume/google"
, body = vars
, encode = "json", verbose())
when I do this for different metrics locations (e.g., 2826 is the UK), it just returns the data for the US which is the default. Is seems to be reading the data in the keyword portion of the list, but then ignoring the rest. The documentation for the API can be found here (unfortunatley the API is paid): https://keywordtool.io/api/documentation#examples
I'm able to get different results for the US and the UK when I format as a php script and run via the terminal, I just don't seem to be able to get it to work with httr. Ideas would be welcome.
edit:
two of the parameters needed to have their values in a list, even if for just one item. poor comprehension on my part.
r post httr
I'm struggling to get httr to work with an API that my company is currently using and for the life of me I can't work out why.
x <- c("Electronic cigarette",
"Cloud-chasing electronic cigarette",
"Safety of electronic cigarettes",
"Electronic cigarette aerosol and liquid",
"Openvape",
"Blu eCigs",
"Regulation of electronic cigarettes",
"PAX Labs",
"Construction of electronic cigarettes",
"Vape shop",
"Hon Lik",
"Dragonite International Limited",
"Positions of medical organizations on electronic cigarettes",
"Evolv",
"List of vaping bans in the United States",
"VMR Products",
"List of electronic cigarette brands",
"Electronic cigarettes in Australia",
"LOGIC electronic cigarette",
"VUSE electronic cigarette",
"NJOY",
"R. J. Reynolds Vapor Company",
"MarkTen",
"Vista Vapors",
"Riccardo Polosa",
"Ten Motives",
)
vars <- list(
keyword = as.character(x),
apikey = "apikeyhere",
metrics_location = "2826",
metrics_language = "en",
metrics_network = "googlesearchnetwork",
metrics_currency = "USD",
output = "json"
)
res <- POST("https://api.keywordtool.io/v2/search/volume/google"
, body = vars
, encode = "json", verbose())
when I do this for different metrics locations (e.g., 2826 is the UK), it just returns the data for the US which is the default. Is seems to be reading the data in the keyword portion of the list, but then ignoring the rest. The documentation for the API can be found here (unfortunatley the API is paid): https://keywordtool.io/api/documentation#examples
I'm able to get different results for the US and the UK when I format as a php script and run via the terminal, I just don't seem to be able to get it to work with httr. Ideas would be welcome.
edit:
two of the parameters needed to have their values in a list, even if for just one item. poor comprehension on my part.
r post httr
r post httr
edited Feb 7 '18 at 13:23
user1200
asked Feb 6 '18 at 18:30
user1200user1200
104
104
If you can get it to work with php, try posting to a site like requestb.in where you can see what's actually being sent to the server. Then compare that to what you get when you usehttr
to do the same. There is likely some difference in the requests you are sending.
– MrFlick
Feb 6 '18 at 19:12
thanks @MrFlick, good suggestion. I've uploaded the output to imgur: imgur.com/a/T6rkc the output nearest the top is a php script, the lower is httr. The headers are different, but not in a way that seems relevant to the differing output, as far as I can tell.
– user1200
Feb 7 '18 at 8:23
add a comment |
If you can get it to work with php, try posting to a site like requestb.in where you can see what's actually being sent to the server. Then compare that to what you get when you usehttr
to do the same. There is likely some difference in the requests you are sending.
– MrFlick
Feb 6 '18 at 19:12
thanks @MrFlick, good suggestion. I've uploaded the output to imgur: imgur.com/a/T6rkc the output nearest the top is a php script, the lower is httr. The headers are different, but not in a way that seems relevant to the differing output, as far as I can tell.
– user1200
Feb 7 '18 at 8:23
If you can get it to work with php, try posting to a site like requestb.in where you can see what's actually being sent to the server. Then compare that to what you get when you use
httr
to do the same. There is likely some difference in the requests you are sending.– MrFlick
Feb 6 '18 at 19:12
If you can get it to work with php, try posting to a site like requestb.in where you can see what's actually being sent to the server. Then compare that to what you get when you use
httr
to do the same. There is likely some difference in the requests you are sending.– MrFlick
Feb 6 '18 at 19:12
thanks @MrFlick, good suggestion. I've uploaded the output to imgur: imgur.com/a/T6rkc the output nearest the top is a php script, the lower is httr. The headers are different, but not in a way that seems relevant to the differing output, as far as I can tell.
– user1200
Feb 7 '18 at 8:23
thanks @MrFlick, good suggestion. I've uploaded the output to imgur: imgur.com/a/T6rkc the output nearest the top is a php script, the lower is httr. The headers are different, but not in a way that seems relevant to the differing output, as far as I can tell.
– user1200
Feb 7 '18 at 8:23
add a comment |
1 Answer
1
active
oldest
votes
There seems to be a problem with the params , the metrics_location seems to be overwritten by the default GLOBAL/ENGLISH or its not loaded .
First check https://keywordtool.io/api .
Then simply add: "https://api.keywordtool.io/v2/search/volume/google?metrics_location=[NUMBERS] to the url . It worked for me .
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f48649657%2fhttr-post-with-keywordtool-io%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
There seems to be a problem with the params , the metrics_location seems to be overwritten by the default GLOBAL/ENGLISH or its not loaded .
First check https://keywordtool.io/api .
Then simply add: "https://api.keywordtool.io/v2/search/volume/google?metrics_location=[NUMBERS] to the url . It worked for me .
add a comment |
There seems to be a problem with the params , the metrics_location seems to be overwritten by the default GLOBAL/ENGLISH or its not loaded .
First check https://keywordtool.io/api .
Then simply add: "https://api.keywordtool.io/v2/search/volume/google?metrics_location=[NUMBERS] to the url . It worked for me .
add a comment |
There seems to be a problem with the params , the metrics_location seems to be overwritten by the default GLOBAL/ENGLISH or its not loaded .
First check https://keywordtool.io/api .
Then simply add: "https://api.keywordtool.io/v2/search/volume/google?metrics_location=[NUMBERS] to the url . It worked for me .
There seems to be a problem with the params , the metrics_location seems to be overwritten by the default GLOBAL/ENGLISH or its not loaded .
First check https://keywordtool.io/api .
Then simply add: "https://api.keywordtool.io/v2/search/volume/google?metrics_location=[NUMBERS] to the url . It worked for me .
answered Nov 16 '18 at 13:45
MariusMarius
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f48649657%2fhttr-post-with-keywordtool-io%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
If you can get it to work with php, try posting to a site like requestb.in where you can see what's actually being sent to the server. Then compare that to what you get when you use
httr
to do the same. There is likely some difference in the requests you are sending.– MrFlick
Feb 6 '18 at 19:12
thanks @MrFlick, good suggestion. I've uploaded the output to imgur: imgur.com/a/T6rkc the output nearest the top is a php script, the lower is httr. The headers are different, but not in a way that seems relevant to the differing output, as far as I can tell.
– user1200
Feb 7 '18 at 8:23