-1
"idealista"(link)のAPIからリクエストをしようとしています。RのGETからidealista APIへのリクエストを行うことができません
それはとても私がやったことは次だった、認証を必要としますので、
if(!require("jsonlite")){install.packages("jsonlite")}
if(!require("httr")){install.packages("httr")}
consumer_key <- "my_key"
consumer_secret <- "my_secret"
#Use basic auth
secret <- jsonlite::base64_enc(paste(consumer_key, consumer_secret, sep = ":"))
req <- httr::POST("https://api.idealista.com/oauth/token",
httr::add_headers(
"Authorization" = paste("Basic", gsub("\n", "", secret)),
"Content-Type" = "application/x-www-form-urlencoded;charset=UTF-8"
),
body = "grant_type=client_credentials"
)
#Extract the access token
token <- paste("Bearer", jsonlite::base64_enc(httr::content(req)$access_token))
、最初:トークンはbase64エンコードされるようにしなければならない場合、私は(私はそう思う)知りません。そして、私は要求するために次の手順を実行します
url<-"https://api.idealista.com/3.5/es/search?locale=es&maxItems=20&numPage=1&operation=sale&order=publicationDate&propertyType=garages&apikey=my_key&t=1&language=es&bankOffer=true" #an example of url (needs apikey)
req <- httr::GET(url, httr::add_headers("Authorization" = token))
をし、応答は次のとおりです。
感覚を持っていないResponse [https://api.idealista.com/3.5/es/search?locale=es&maxItems=20&numPage=1&operation=sale&order=publicationDate&propertyType=garages&apikey=80gzxznozajnl3tf30ite86k1p24e4yb&t=1&language=es&bankOffer=true]
Date: 2017-10-10 15:25
Status: 400
Content-Type: text/html
Size: 4.4 kB
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/T...
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es_ES" lang="es_ES">
<head>
<title>idealista.com : pisos madrid, pisos barcelona, pisos v...
<meta http-equiv="content-Type" content="text/html; charset=I...
<meta http-equiv="Expires" content="0"/>
<meta name="Pragma" content="no-cache"/>
<meta http-equiv="pragma" content="no-cache"/>
<meta http-equiv="cache-control" content="no-cache, mustreval...
...
。私が悪いことを教えてくれますか? 私が受け取るステータスコードは「400」です。私は何をすべきかわかりません。
ありがとうございます。
これはidealista.com APIに完全に固有のようです。おそらくサポートに連絡するべきです。または少なくとも、APIの関連文書の関連部分をリンクしてください。本当に2つの認証ヘッダーを追加しようとしていますか? – MrFlick