mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-09-04 06:46:31 +00:00
Fix #553: Add example for sending a POST request with XML data
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use \Curl\Curl;
|
||||
|
||||
$data = '<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rss>
|
||||
<items>
|
||||
<item>
|
||||
<id>1</id>
|
||||
<ref>33ee7e1eb504b6619c1b445ca1442c21</ref>
|
||||
<title><![CDATA[The Title]]></title>
|
||||
<description><![CDATA[The description.]]></description>
|
||||
<link><![CDATA[https://www.example.com/page.html?foo=bar&baz=wibble#hash]]></link>
|
||||
</item>
|
||||
<item>
|
||||
<id>2</id>
|
||||
<ref>b5c0b187fe309af0f4d35982fd961d7e</ref>
|
||||
<title><![CDATA[Another Title]]></title>
|
||||
<description><![CDATA[Some description.]]></description>
|
||||
<link><![CDATA[https://www.example.org/image.png?w=1265.73&h=782.26]]></link>
|
||||
</item>
|
||||
</items>
|
||||
</rss>';
|
||||
|
||||
$curl = new Curl();
|
||||
$curl->setHeader('Content-Type', 'text/xml');
|
||||
$curl->post('https://httpbin.org/post', $data);
|
||||
var_dump($curl->response);
|
||||
Reference in New Issue
Block a user