I'm new to sending, receiving, and reading XML. I'm trying to send and receive XML data via cURL. I am using curl because it was so easy with just arrays. I am using the following code to generate the XML and the PHP script that is presently not working. It would be great if some great code god can explain whats wrong to me.
build_xml.php -
<?php
-
'<?xml version="1.0"?>'
-
$xml = "<member><name>name</name></member>";
-
echo $xml;
-
?>
-
Array Method - Works great with arrays. I tried with XML as $data, and it no work. Getting it working this way is preferred. -
<?php
-
exec("/usr/bin/curl -m 120 -d \"$xml\" http://www.example.com/index.php -L", $response);
-
// $response is null
-
?>
-
Alternate Method - This way is failing also. -
<?php
-
$url = "build_xml.php";
-
$ch = curl_init(); // initialize curl handle
-
curl_setopt($ch, CURLOPT_URL,$url); // set url to post to
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
-
curl_setopt($ch, CURLOPT_TIMEOUT, 4); // times out after 4s
-
curl_setopt($ch, CURLOPT_POSTFIELDS, $XPost); // add POST fields
-
$result = curl_exec($ch); // run the whole process
-
echo $result; //contains response from server
-
// NO RESPONSE RECEIVED
-
?>
-
3 3998
Heya, empiresolutions.
build_xml.php -
<?php
-
'<?xml version="1.0"?>'
-
$xml = "<member><name>name</name></member>";
-
echo $xml;
-
?>
-
In this code, you're not actually outputting the XML header. Is this intentional?
Perhaps you meant to do this instead: -
<?php
-
$xml = '
-
<?xml version="1.0" encoding="utf-8"?>
-
<member>
-
<name>name</name>
-
</member>';
-
-
return $xml;
-
?>
-
Then in your main code: -
$xml = require('build_xml.php');
-
Heya, empiresolutions.
Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Haluk Durmus |
last post by:
Hello
I checked out openssl,mm,apr,apr-util,apache 2,curl,libxml and php
from cvs.
php couse an ERROR
I did the following steps:
|
by: Stefan Richter |
last post by:
Hi, I would like to conect to a server by a SSL Conection,
to send an SMS.
The company that offers the SMS service provided some Code for a http
connection, but not for a https connection.
Here...
|
by: Chris Fortune |
last post by:
# uname -a
Linux stargate.mxc-online.net 2.4.20-021stab022.2.777-smp #1 SMP Wed Jul 28
17:12:37
MSD 2004 i686 i686 i386 GNU/Linux
I recompiled PHP with mcrypt, openssl, and curl
phpinfo():...
|
by: Edwin Rozie |
last post by:
Hey can U help me with the following?
I would like to send basic data (like a set of integers & strings) from
one php function to another php function.
Sounds easy, However, the functions are...
|
by: yawnmoth |
last post by:
Is it possible to send http requests with curl but not have curl wait
for the response?
The reason I ask is because I'd like to code a web app that can sorta
start time consuming processes...
|
by: nfhm2k |
last post by:
I've been trying to find a solution to this for quite some time now...
I even took a look at existing scripts...
Including this one......
|
by: Miro |
last post by:
VB 2003
at the end of the code, this works great.
bytCommand = Encoding.ASCII.GetBytes("testing hello send text")
udpClient.Send(bytCommand, bytCommand.Length)
and this recieves it
Dim...
|
by: existatus |
last post by:
In a form there are entries like this:
<input type="text" name="first_name" size="24" />
<input type="text" name="last_name" size="24" />
<input type="hidden" name="must_have" value="12345" />...
|
by: lakmarket |
last post by:
Hi,
I am trying to send some querysting using cURL. This is the working
API
...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |