2010-10-26 9 views
0

J'ai vérifié que $requestDom->saveXml() renvoie un code XML valide mais à l'URL de destination j'ai print_r ($ _ POST) et il ne reçoit rien. Est-ce que j'ai râté quelque chose? : - \Les champs POST Curl ne sont pas affichés

$connection = curl_init(); 
    curl_setopt($connection, CURLOPT_POSTFIELDS, array(
     'xml' => $requestDom->saveXml() 
    )); 
    curl_setopt($connection, CURLOPT_HEADER, false); //with or without this option, it doesn't work 
    curl_setopt($connection, CURLOPT_RETURNTRANSFER, true); 
    curl_setopt($connection, CURLOPT_POST, true); 
    curl_setopt($connection, CURLOPT_URL, 'http://sample.com'); 

    $response = curl_exec($connection); 

Répondre

1

Après d'autres recherches, j'ai découvert que la méthode appropriée pour afficher xml à une URL de destination est à ....

$connection = curl_init(); 
curl_setopt($connection, CURLOPT_POSTFIELDS, $requestDom->saveXml()); 
curl_setopt($connection, CURLOPT_HEADER, false); //with or without this option, it doesn't work 
curl_setopt($connection, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($connection, CURLOPT_POST, true); 
curl_setopt($connection, CURLOPT_URL, 'http://sample.com'); 

$response = curl_exec($connection); 

Et puis sur le fichier reçu ces informations, utilisez:

  $post = file_get_contents("php://input"); 
      $request = simplexml_load_string($post); 
0

Je peux reproduire le problème. Demandez de l'aide dans le canal # php.pecl sur EFnet.

Questions connexes