0

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 エンベロープで配列を渡すにはどうすればよいですか?

4

1 に答える 1

0

私は答えを見つけました。

私の主な問題は、彼らが Web ページで公開したエンドポイント URL を使用して API を呼び出していたことです。ただし、この URL でこの .wsdl ファイルをダウンロードし、内部を調べて API を呼び出す実際の URL ( https://api.verticalresponse.com/1.0/VRAPI ) を確認する必要がありました。.wsdl ファイルは、使用する適切な SOAP アクション名も示します。名前空間も適切に指定する必要があります。

以下は完成した作業結果です。

Function VRLogin() As String

   Dim sURL As String
   Dim sEnv As String
   Dim xmlhtp As New MSXML2.XMLHTTP

   sURL = "https://api.verticalresponse.com/1.0/VRAPI"

   sEnv = "<?xml version=""1.0"" encoding=""UTF-8""?>"
   sEnv = sEnv & "<SOAP-ENV:Envelope xmlns:SOAP-ENV=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:ns1=""VR/API/1_0"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:ns2=""http://api.verticalresponse.com/1.0/VRAPI.xsd"" xmlns:SOAP-ENC=""http://schemas.xmlsoap.org/soap/encoding/"" SOAP-ENV:encodingStyle=""http://schemas.xmlsoap.org/soap/encoding/"">"
   sEnv = sEnv & "    <SOAP-ENV:Body>"
   sEnv = sEnv & "        <ns1:login>"
   sEnv = sEnv & "            <args xsi:type=""ns2:loginArgs"">"
   sEnv = sEnv & "                <username xsi:type=""xsd:string"">first-last@yahoo.com</username>"
   sEnv = sEnv & "                <password xsi:type=""xsd:string"">xxxxxxxx</password>"
   sEnv = sEnv & "                <session_duration_minutes xsi:type=""xsd:integer"">120</session_duration_minutes>"
   sEnv = sEnv & "            </args>"
   sEnv = sEnv & "        </ns1:login>"
   sEnv = sEnv & "    </SOAP-ENV:Body>"
   sEnv = sEnv & "</SOAP-ENV:Envelope>"

   xmlhtp.Open "post", sURL, False
   xmlhtp.setRequestHeader "Content-Type", "text/xml"

   xmlhtp.setRequestHeader "SOAPAction", "VR/API/1_0#login"
   xmlhtp.send sEnv

   VRLogin = xmlhtp.ResponseText

End Function
于 2013-09-06T02:57:36.253 に答える