开发者

Symfony2 sending XML to a remote URL

开发者 https://www.devze.com 2023-04-09 13:02 出处:网络
I would like to send XML data to a remote URL. How to do this in a proper开发者_如何转开发 way using Symfony2?

I would like to send XML data to a remote URL. How to do this in a proper开发者_如何转开发 way using Symfony2?

Equivalent in flat PHP using curl would be:

$ch = curl_init("http://website");
$request["queue"] = file_get_contents("file_to_send.xml");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
$response = curl_exec($ch);
curl_close ($ch);


Well, from here it looks like a good way to do it. Don't forget, keep it simple.

You might want to wrap it in some class that would manager communication with other servers. This way it would be more testable.

0

精彩评论

暂无评论...
验证码 换一张
取 消