所以我想使用curl使用MyAnimeList Api更新我的特定系列列表中的剧集。当我想发布XML数据时,它会给我一个Invalid XML format
响应。我已经看过一些帖子说你应该首先对数据进行编码,但是没有解决它(使用this one或this one等在线工具。)
curl -u "<dummyuser>:<dummypass>" -d data="<?xml version="1.0" encoding="UTF-8"?><entry><episode>18</episode><status>1</status><score>7</score><storage_type></storage_type><storage_value></storage_value><times_rewatched></times_rewatched><rewatch_value></rewatch_value><date_start></date_start><date_finish></date_finish><priority></priority><enable_discussion></enable_discussion><enable_rewatching></enable_rewatching><comments></comments><tags></tags></entry>" -k https://myanimelist.net/api/animelist/update/7791.xml
感谢任何帮助。
答案 0 :(得分:0)
在curl语句中,您使用与标记XML字符串(例如version="1.0"
)的标记值相同的引号。所以在整个-d值周围使用单引号......
curl -u "<dummyuser>:<dummypass>" -d data='<?xml version="1.0" encoding="UTF-8"?><entry><episode>18</episode><status>1</status><score>7</score><storage_type></storage_type><storage_value></storage_value><times_rewatched></times_rewatched><rewatch_value></rewatch_value><date_start></date_start><date_finish></date_finish><priority></priority><enable_discussion></enable_discussion><enable_rewatching></enable_rewatching><comments></comments><tags></tags></entry>' -k https://myanimelist.net/api/animelist/update/7791.xml
答案 1 :(得分:0)
GET
而非POST
网址编码数据
curl -u "username:password" -d data="%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%3F%3E%3Centry%3E%3Cepisode%3E18%3C%2Fepisode%3E%3Cstatus%3E1%3C%2Fstatus%3E%3Cscore%3E7%3C%2Fscore%3E%3Cstorage_type%3E%3C%2Fstorage_type%3E%3Cstorage_value%3E%3C%2Fstorage_value%3E%3Ctimes_rewatched%3E%3C%2Ftimes_rewatched%3E%3Crewatch_value%3E%3C%2Frewatch_value%3E%3Cdate_start%3E%3C%2Fdate_start%3E%3Cdate_finish%3E%3C%2Fdate_finish%3E%3Cpriority%3E%3C%2Fpriority%3E%3Cenable_discussion%3E%3C%2Fenable_discussion%3E%3Cenable_rewatching%3E%3C%2Fenable_rewatching%3E%3Ccomments%3E%3C%2Fcomments%3E%3Ctags%3E%3C%2Ftags%3E%3C%2Fentry%3E" -k https://myanimelist.net/api/animelist/update/7791.xml -g