XML php curl 请求不支持的媒体类型


Unsupported media type for xml php curl request

这是我用来连接到Mind Body Online API的代码。 如果有人对此有任何经验,请指出我正确的方向!

我得到的错误是:服务器无法为请求提供服务,因为媒体类型不受支持。

法典:

$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:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Header/>
  <soapenv:Body>
     <GetClasses xmlns="http://clients.mindbodyonline.com/api/0_5/GetClasses">
        <Request>
           <SourceCredentials>
              <SourceName>{user}</SourceName>
              <Password>{pass}</Password>
              <SiteIDs>
                 <int>{id}</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: application/xml;charset=utf-8",
    "Accept: application/xml",
    "Cache-Control: no-cache",
    "Pragma: no-cache",
    "SOAPAction: http://clients.mindbodyonline.com/api/0_5/GetClasses",
    "Content-length: ".strlen($xml_post_string),
    );
$url = $soapUrl;
$cookiePath = tempnam('/tmp', 'cookie');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiePath);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// converting
$response = curl_exec($ch);
curl_close($ch);
echo $response;
"Content-type: text/xml;charset=utf-8"
<?php
function getAccessToken()
{
$head = array("Accept" =>"application/json",
                  "Content-type" => "multipart/form-data");
$header="";
foreach ($head as $key => $value) {
    $header .= $key . '=' . $value . '&';
}
$header = rtrim($header, '&');
$parameters="";
$params = array("grant_type"=>"client_credentials");
foreach ($params as $key => $value) {
    $parameters .= $key . '=' . $value . '&';
}
$parameters = rtrim($parameters, '&');
$url = "https://api.sandbox.paypal.com/v1/oauth2/token";
$ch = curl_init();
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_HEADER, $header);
curl_setopt($ch,CURLOPT_POSTFIELDS,$parameters);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_USERPWD, "ASLy4BAtBdBh1B2XfPpVdffdfdsfdutPM4l-sAnIWzrmLJ_2Y-    7VcU4qC_tH:EAH5UhDznr8jAZYeSDtODz9I2qT8WOuq2tiAJwY8HdvMN7cP3isdsdsdgy");
    $response = curl_exec($ch);
    if (empty ($response) )
    {
        die (curl_error($ch));
    }
      print_r($response);
      }
     getAccessToken();