imgflip API (https://api.imgflip.com/) 的 R 接口.总是以失败“未提供文本"结束 [英] R interface to imgflip API (https://api.imgflip.com/). Always ends in with the failure "No texts supplied"
本文介绍了imgflip API (https://api.imgflip.com/) 的 R 接口.总是以失败“未提供文本"结束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用 httr
包的简单帖子总是以错误结束?
A simple post using the httr
package always ends with an error?
# Post a random meme and print its url
res <- httr::POST(
url = "https://api.imgflip.com/caption_image",
body = list(
template_id = "61579",
username = "<my-username>",
password = "<my-password>",
text0 = "abc",
text1 = "def",
font = "impact",
max_font_size = "50"
),
httr::verbose(),
encode = "json"
)
httr::content(res, "text")
推荐答案
我不知道如何在 R 中做到这一点,但我尝试使用 postman
并将请求作为 JSON发送code> 不起作用,您必须将其作为
form-data
发送:
Im not sure how to do it in R, but I tried using postman
and sending the request as JSON
do not work you have to send it as a form-data
:
这篇关于imgflip API (https://api.imgflip.com/) 的 R 接口.总是以失败“未提供文本"结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文