2017-03-17 4 views
0

Ich versuche, Service mit drei Parametern aufrufen: URI, Code und Typ. Aber manchmal "Typ" Parameter Buchung leer, manchmal Buchung korrekt. Serviceaufruf manchmal erfolgreich, manchmal fehlgeschlagen. Ich ändere nichts, aber der Parameter "type" ist manchmal leer. Wie kann ich dieses Problem lösen?Php Curl Post Daten Parameter manchmal leer gesendet

$curl_post_data = array( 
     "uri" => $uri, 
     "code" => $code, 
     "type" => $type 
    ); 

$post_data = http_build_query($curl_post_data); 
$curl = curl_init($service_url); 
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 60); 
curl_setopt($curl, CURLOPT_TIMEOUT, 10); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); 
curl_setopt($curl, CURLOPT_POST, true); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data); 
curl_setopt($curl, CURLOPT_HEADER, false); 
curl_setopt($curl, CURLOPT_HTTPAUTH, xxx); 
curl_setopt($curl, CURLOPT_USERPWD, xxx); 
curl_setopt($curl, CURLOPT_PROXY, 'xxx'); 
curl_setopt($curl, CURLOPT_PROXYUSERPWD, 'xxxx'); 
curl_setopt($curl, CURLOPT_PROXYPORT, xxx); 
curl_setopt($curl, CURLOPT_PROXYAUTH, xxx); 
$curl_response = curl_exec($curl); 
if (false === $curl_response) { 
    return null; 
} 
+0

Können Sie helfen? Stack Overflow hängt davon ab, ob jeder sein Wissen teilt. Wenn Sie diese Frage beantworten können, tun Sie es bitte! – stef

Antwort

0

http_build_query werden NULL-Werte entfernen .. siehe ersten Kommentar: http://php.net/manual/en/function.http-build-query.php

+0

Ich habe keinen Nullwert gesendet. Es ist immer voll. Aber es funktioniert nicht. – stef

+0

naja, es ist etwas, in das man schauen kann, da wir nicht sehen können, wie '$ type' Wert gefüllt wird. Sie sagten, es sei leer, also ging ich mit dem .. – Rick