Access で VBA を使用して、垂直応答の API で動作する SOAP ログイン メソッドを取得しようとしています。彼らは例を使って VBA を宣伝するのではなく、Java や PHP などでサポートされているツールや例を使用することを提案しています。
http://developers.verticalresponse.com/api/の API ドキュメント ページで、エンドポイントは https://api.verticalresponse.com/wsdl/1.0/VRAPI.wsdlであると述べています。
API ドキュメント ページでは、ログインを説明するリンクが [Misc Methods] タブにあります。
入力引数は次のように記述されます。
username [xsd:string]
password [xsd:string]
session_duration_minutes [xsd:integer]
URL、SOAP エンベロープ、およびヘッダーのバリエーションを使用して、次の VBA コードを試しました。セッション ID を取得したことはありませんが、以下に示す役に立たないテキストが常に表示されます。
Function VRLogin() As String
Dim sURL As String
Dim sEnv As String
Dim xmlhtp As New MSXML2.XMLHTTP
sURL = "https://api.verticalresponse.com/wsdl/1.0/VRAPI"
sEnv = sEnv & "<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">"
sEnv = sEnv & " <soap:Body>"
sEnv = sEnv & " <username>firstname-lastname@yahoo.com</username>"
sEnv = sEnv & " <password>xxxxxxxx</password>"
sEnv = sEnv & " <session_duration_minutes>120</session_duration_minutes>"
sEnv = sEnv & " </soap:Body>"
sEnv = sEnv & "</soap:Envelope>"
xmlhtp.Open "post", sURL, False
xmlhtp.setRequestHeader "Content-Type", "text/xml"
xmlhtp.setRequestHeader "SOAPAction", "login"
xmlhtp.send sEnv
VRLogin = xmlhtp.ResponseText
End Function
URL に次のバリエーションがあります。
sURL = "https://api.verticalresponse.com/wsdl/1.0/VRAPI"
sURL = "https://api.verticalresponse.com/wsdl/1.0/login"
sURL = "https://api.verticalresponse.com/wsdl/1.0/VRAPI/login"
sURL = "https://api.verticalresponse.com/wsdl/1.0/VRAPI?method=login"
sURL = "https://api.verticalresponse.com/login"
応答テキストは次のようになります。
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>404 Not Found</TITLE>
</HEAD><BODY>
<H1>Not Found</H1>
The requested URL /wsdl/1.0/VRAPI was not found on this server.<P>
</BODY></HTML>
次のいずれかのように、URL に「wsdl」が含まれている場合:
sURL = "https://api.verticalresponse.com/wsdl/1.0/VRAPI.wsdl"
sURL = "https://api.verticalresponse.com/wsdl/1.0/VRAPI.wsdl/login"
sURL = "https://api.verticalresponse.com/wsdl/1.0/VRAPI.wsdl?method=login"
応答テキストは wsdl ドキュメントです。
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:vrns="http://api.verticalresponse.com/1.0/VRAPI" xmlns:vrtypens="http://api.verticalresponse.com/1.0/VRAPI.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:vr="http://www.verticalresponse.com/vrns" targetNamespace="http://api.verticalresponse.com/1.0/VRAPI" name="VRAPI">
<wsdl:types>
<xsd:schema targetNamespace="http://api.verticalresponse.com/1.0/VRAPI.xsd">
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/"/>
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<xsd:complexType name="ArrayOfCampaignContentLink">
<xsd:complexContent>
<xsd:restriction base="soapenc:Array">
<xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="vrtypens:CampaignContentLink[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
etc ...
また、SOAP エンベロープに「xsd:」を追加しようとしましたが、いくつかの例で見たように、次のように役に立ちませんでした。
sEnv = sEnv & " <xsd:username>firstname-lastname@yahoo.com</xsd:username>"
sEnv = sEnv & " <xsd:password>xxxxxxxx</xsd:password>"
sEnv = sEnv & " <xsd:session_duration_minutes>120</xsd:session_duration_minutes>"
Content-type などのヘッダーを変更し、ヘッダーを削除して、次のような完全修飾 SOAPAction ヘッダーを作成しましたが、成功しませんでした。
xmlhtp.setRequestHeader "SOAPAction", "https://api.verticalresponse.com/wsdl/1.0/VRAPI/login"
私の API アクセスは有効になっていますが、私の結果によると、認証に関してはそれほど進んでいないことが示されています。これは、URL、SOAP エンベロープ、またはヘッダーのいずれかに問題があると思います。
エンドポイントとその入力を使用したログインについて提供される情報から、VBA を使用して API 呼び出しをセットアップできるはずです。この質問は、Vertical Response API に固有のものではありません。
私が欠けているものを見ることができますか?
また、これは別の質問かもしれませんが、関連しており、API を呼び出す必要があります。
SOAP エンベロープで配列を渡すにはどうすればよいですか?