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 22:12:58 -0500

oh, you'll then need to use CURLOPT_HTTPHEADER to which you can send an
array of header fields to set...

-----Original Message-----
From: Eddy Oretap <eddy_at_owss.no>
To: using curl with PHP <curl-and-php_at_cool.haxx.se>
Date: Wed, 21 Jul 2004 00:55:40 +0200
Subject: Re: cURL -> PHP -> XML

Thanx Steve

I have tryed that but the problem is that I have to set the HEADERS just
right as described in the file! how?

Content-type: application/xml
Content-length: 184

and also the HTTP/1.0 must be set.

At 17:15 20.07.2004 -0500, you wrote:

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!

---
Eddy Oreatp
Daglig leder
+47 924 89 648
OWSS.NO 
Received on 2004-07-21