$ length = strlen ($ requestXml); $ ch = curl_init ($ serviceUrl);Nicht korrekte Antwort in CURL Seife PHP
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: text/xml; charset=utf-8',
"SOAPAction: \"https://example.com/PMAPI/example/$action\"",
"Content-length: ".strlen($requestXml)
));
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestXml);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, $username . ':' . $password);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookieFIle.txt");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookieFIle.txt");
curl_setopt($ch, CURLOPT_HEADER, 0);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
$xml= simplexml_load_string($output);
print_r($xml);
Ausgang Ich erhalte:
, die nicht im XML-Format ist. Aber in View Source Der Code ist im XML-Format. Aber es hat nicht funktioniert, wenn ich diese Ausgabezeichenfolge in Xml Parser analysiere.
Ausgabe sollte in folgendem Format sein, das ich auf der View-Source-Seite sehen kann.
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><TopUpRequestResponse xmlns="https://dollarphone.com/PMAPI/PinManager"><TopUpRequestResult><responseCode>1</responseCode><TransId>27464347</TransId></TopUpRequestResult></TopUpRequestResponse></soap:Body></soap:Envelope>
Wenn ich versuche, auf das Objekt zuzugreifen. Der Fehler lautet "Versuch, die Eigenschaft eines Nicht-Objekts zu erhalten".
Bitte jemand helfen mir dieses Problem zu lösen?
Sie scheinen mit curl durch eine Menge Ärger zu gehen. Du weißt, dass es so etwas wie SoapClient gibt, oder? http://php.net/manual/en/class.soapclient.php – 1sloc
Ja, ich weiß. Aber ich habe Authentifizierungsproblem, wenn ich SoapClient versuche, da es NTLM-Authentifizierung ist. – NDesai