cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: cURL -> PHP -> XML

From: Steve Yeazel <syeazel_at_frigidfluidco.com>
Date: Tue, 20 Jul 2004 17:15:02 -0500

to post xml just throw it into a variable and send it like this:

$ch = curl_init(); //initiate the curl session
curl_setopt($ch, CURLOPT_URL, $url); //set to url to post to
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // tell curl to return data
in a variable
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlRequest); // post the xml
curl_setopt($ch, CURLOPT_TIMEOUT, (int)$timeout); // set timeout in seconds
$xmlResponse = curl_exec ($ch);
curl_close ($ch);

if all goes well then $xmlResult should contain your returned xml

At 04:58 PM 7/20/2004, you wrote:

>Hi ppl
>
>I'm quite new to cURL but have used PHP for years now and I got a problem
>as follows:
>
>I have to send this as a HTTP POST using cURL in PHP:
>
>POST /sms HTTP/1.0
>Host: sms3.pswin.com
>Content-type: application/xml
>Content-length: 184
>
><?xml version="1.0"?>
><SESSION>
><CLIENT>demo1</CLIENT>
><PW>demo1</PW>
><MSGLST>
><MSG>
><ID>1</ID>
><TEXT>Test message</TEXT>
><RCV>4712345678</RCV>
><SND>4711111111</SND>
></MSG>
></MSGLST>
></SESSION>
>
>And I'll get a response looking like this back:
>
>HTTP/1.1 200 Ok
>Server: sms3.pswin.com
>Content-type: application/xml
>Content-length: 156
>
><?xml version="1.0"?>
><SESSION>
><LOGON>OK</LOGON>
><REASON></REASON>
><MSGLST>
><MSG>
><ID>1</ID>
><STATUS>OK</STATUS>
><INFO></INFO>
></MSG>
></MSGLST>
></SESSION>
>
>So they say.
>
>Could someone plz help me to get this together so I can use cURL to send
>and receive this data.
>
>the XML part is easy to get together so its the CURL part I need help to
>solve!
>
>
Received on 2004-07-21