微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

来自Eikon Cloud的R检索信息

如何解决来自Eikon Cloud的R检索信息

我正在尝试从Eikon Elektron云平台获取数据。

我从https://github.com/Refinitiv/websocket-api/blob/master/Applications/Examples/R/market_price_authentication.R运行了以下代码

library(curl)
> content = paste("grant_type=","password","&username=",user,"&password=",password,sep="") 
> h <- new_handle(copypostfields = content) 
> h 
<curl handle> (empty) 
> handle_setheaders(h,+ "Content-Type" = "application/x-www-form-urlencoded" 
+ ) 
> handle_setopt(h,ssl_verifypeer = FALSE,ssl_verifyhost = FALSE) 
> auth_url = paste("https://",auth_hostname,sep="")# ":",auth_port,"/getToken",sep="") 
> auth_url 
[1] "https://api.refinitiv.com/auth/oauth2/v1/token" 
> req <- curl_fetch_memory(auth_url,**handle = h**) 
> req 
$url 
[1] "https://api.refinitiv.com/auth/oauth2/v1/token" 

$status_code 
[1] 400 

$type 
[1] "application/json" 

**> h 
<curl handle> (https://api.refinitiv.com/auth/oauth2/v1/token)**

> res_headers = parse_headers(req$headers) 
> auth_json_string = rawtochar(req$content) 
> auth_json = fromJSON(auth_json_string) 
> cat(toJSON(auth_json,pretty=TRUE,auto_unBox=TRUE)) 
{ 
"error": "invalid_request" 
}

如您所见,我收到了无效的请求错误。我认为问题出在curl_fetch_memory上,并且handle=h使用的输入与auth_url相同,但是应该使用与content相似的输入。我可以在代码中进行哪些更改才能使其正常工作?

解决方法

我找到了如何访问URL的解决方案。在github中写错了R文件中的app_id应该等于路透社App Key生成器中的代码。但是,app_id和client_id是不同的东西,您应该在App Key生成器中添加client_id = value(而不是app_id)。+也不要忘记在内容中包含trapi等。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。