我正在尝试使用API更新在线数据库。
该API由一个法国站点托管,使用细节很少,没有示例。
这是他们提供的信息。
The query must be sent as a "multipart / form-data" html form using the "POST" method.
Input parameters:
ssid : (type "text") user's ScreenScraper identifier
sspassword : (type "text") ScreenScraper password of the user
gameid : (type "text") numerical identifier of the game on ScreenScraper
or
romid ( "text") numeric ID of the Roma on ScreenScraper
to propose a textual info:
modiftypeinfo ( "text") type of information sent (see list "modiftypeinfo")
modifregion ( "text"
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<META http-equiv="content-language" content="fr">
<title></title>
</head>
<body>
<form name="myform" id="myform" method="post" enctype="multipart/form-data" action="https://www.screenscraper.fr/api/botProposition.php?ssid=xxx&sspassword=yyy">
<input type="text" name="gameid" value="3">
<input type="text" name="modiftypeinfo" value="description">
<input type="text" name="modifregion" value="">
<input type="text" name="modiflangue" value="fr">
<input type="text" name="modifversion" value="">
<input type="text" name="modiftexte" value="ici, le synopsis du jeu ! ne pas valider, c'est un test ;)">
<input type="text" name="modifsource" value="botProposition / source de l'info">
<input type="submit" value="envoyer">
</form>
<script>
document.getElementById("myform").submit();
</script>
</body>
</html>
这是我编写的代码:
Sub Post_Detail()
Dim xmlhttp As Object, response As String, SendString As String
Set xmlhttp = CreateObject("MSXML2.XMLHTTP.6.0")
'~~> Indicates that page that will receive the request and the type of request being submitted
xmlhttp.Open "POST", "https://www.screenscraper.fr/api/botProposition.php?ssid=xxx&sspassword=yyy", False
'~~> Indicate that the body of the request contains form data
xmlhttp.setRequestHeader "Content-Type", "text/html; charset=UTF-8"
xmlhttp.setRequestHeader "enctype", "multipart/form-data"
'~~> Send the data as name/value pairs
SendString = "&type=text&name=gameid&value=185882"
SendString = SendString & "&type=text&name=modiftypeinfo&value=genres"
SendString = SendString & "&type=text&name=modiftexte&value=Sports"
SendString = SendString & "&type=submit&value=envoyer"
Debug.Print SendString
xmlhttp.send SendString
response = xmlhttp.responseText
MsgBox response
Set xmlhttp = Nothing
End Sub
我不确定该怎么处理这个部分:form name="myform" id="myform"
的指令,也不确定我的通过构建字符串的请求是否正确。
如果没有登录,你将无法运行,它会返回密码无效的错误。