Skip to content

Commit c2f47ca

Browse files
committed
Fix php-curl-class#553: Add example for sending a POST request with XML data
1 parent 538524f commit c2f47ca

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

examples/post_xml.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
require __DIR__ . '/../vendor/autoload.php';
3+
4+
use \Curl\Curl;
5+
6+
$data = '<?xml version="1.0" encoding="UTF-8"?>
7+
<rss>
8+
<items>
9+
<item>
10+
<id>1</id>
11+
<ref>33ee7e1eb504b6619c1b445ca1442c21</ref>
12+
<title><![CDATA[The Title]]></title>
13+
<description><![CDATA[The description.]]></description>
14+
<link><![CDATA[https://www.example.com/page.html?foo=bar&baz=wibble#hash]]></link>
15+
</item>
16+
<item>
17+
<id>2</id>
18+
<ref>b5c0b187fe309af0f4d35982fd961d7e</ref>
19+
<title><![CDATA[Another Title]]></title>
20+
<description><![CDATA[Some description.]]></description>
21+
<link><![CDATA[https://www.example.org/image.png?w=1265.73&h=782.26]]></link>
22+
</item>
23+
</items>
24+
</rss>';
25+
26+
$curl = new Curl();
27+
$curl->setHeader('Content-Type', 'text/xml');
28+
$curl->post('https://httpbin.org/post', $data);
29+
var_dump($curl->response);

0 commit comments

Comments
 (0)