我想与F.A.C.E.联系API。我创建了免费试用版,获得了API密钥...但是我无法连接API。我几乎没有与R进行API连接的经验,因此我正在寻找建议。下面是代码:
library(httr)
library("readxl")
library("XML")
library("jsonlite")
#FACE API
#key https://face-api.sightcorp.com/user-dashboard/
key <- "XXX"
path <- "api-face.sightcorp.com/api/detect/"
img.url <- "http://getwallpapers.com/wallpaper/full/5/6/4/1147292-new-women-faces-wallpaper-2880x1800-for-phone.jpg"
mybody = list(url = img.url)
# Request data from Microsoft
faceResponse = POST(
url = path,
content_type('application/json'), add_headers(.headers = c('Ocp-Apim-Subscription-Key' = key)),
body = mybody,
encode = 'json'
)
# Show request results (if Status=200, request is okay)
faceResponse
#However I get an error:
"Error in curl::curl_fetch_memory(url, handle = handle) :
Failed to connect to localhost port 8080: Connection refused"
我该如何纠正与API的连接?