私は Mind Body Online API に接続しようとしています (彼らのフォーラムは現在ダウンしているので、ここに来ました)。以下は私が使用しているコードです。私はこれを受け取っています:
サーバー エラー 405 - このページへのアクセスに使用される HTTP 動詞は許可されていません。無効なメソッド (HTTP 動詞) を使用してアクセスしようとしたため、お探しのページを表示できません。
コード:
//Data, connection, auth
$soapUrl = "http://clients.mindbodyonline.com/api/0_5/ClassService.asmx?WSDL";
// xml post structure
$xml_post_string = '<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://clients.mindbodyonline.com/api/0_5/GetClasses">
<soapenv:Header/>
<soapenv:Body>
<GetClasses>
<Request>
<SourceCredentials>
<SourceName>{username}</SourceName>
<Password>{password}</Password>
<SiteIDs>
<int>{siteid}</int>
</SiteIDs>
</SourceCredentials>
<XMLDetail>Basic</XMLDetail>
<PageSize>10</PageSize>
<CurrentPageIndex>0</CurrentPageIndex>
<SchedulingWindow>true</SchedulingWindow>
</Request>
</GetClasses>
</soapenv:Body>
</soapenv:Envelope>';
$headers = array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: http://clients.mindbodyonline.com/api/0_5/GetClasses",
"Content-length: ".strlen($xml_post_string),
); //SOAPAction: your op URL
$url = $soapUrl;
// PHP cURL for https connection with auth
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// converting
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
// converting
//$response1 = str_replace("<soap:Body>","",$response);
//$response2 = str_replace("</soap:Body>","",$response1);
// convertingc to XML
//$parser = simplexml_load_string($response2);
// user $parser to get your data out of XML response and to display it.
どんな助けでも素晴らしいでしょう、そして誰かが彼らのAPIを使った経験があれば、私の初めてです;)
これがスタックに関する投稿です 。PHPでのSOAPリクエスト
編集:
応答の var ダンプ:
string(733) "soap:ServerSystem.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object. at mb.API._0_5.ClassService.GetClasses(GetClassesRequest Request) in e:\Builds\1\mb\mb-clients_stageclients\Sources\mb-clients\API\0_5\ClassService.asmx.cs:line 226 --- End of inner exception stack trace ---"