Proper way to send (POST) xml with guzzle 6

后端 未结 2 1313
南旧
南旧 2021-02-12 16:58

I want to perform a post with guzzle sending an xml file. I did not find an example.

What I \'ve done so far is :

$xml2=simplexml_load_string($xml) or d         


        
2条回答
  •  终归单人心
    2021-02-12 17:40

    This is what worked for me on Guzzle 6:

    // configure options
    $options = [
        'headers' => [
            'Content-Type' => 'text/xml; charset=UTF8',
        ],
        'body' => $xml,
    ];
    
    $response = $client->request('POST', $url, $options);
    

提交回复
热议问题