0
0

More than 1 year has passed since last update.

php xml request with curl

Last updated at Posted at 2022-02-24
<?php
       $xmldata = '<?xml version="1.0" encoding="UTF-8"?>
					<student>
					<info>
					<name>Rahul kumar</name>
					<age>10</age>
					<class>5th</class>
					<rollno>25</rollno>
					</info>
					</student>';


        $url = "https://www.website.com/ws";

        $ch = curl_init();
        if (!$ch) {
            die("Couldn't initialize a cURL handle");
        }
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_TIMEOUT, 60);
        curl_setopt($ch, CURLOPT_POST, true);
       curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
        curl_setopt($ch, CURLOPT_POSTFIELDS, $xmldata);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        $result = curl_exec($ch); // execute
	echo $result;             //show response
	curl_close($ch);
?>

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0