473,788 Members | 2,807 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sending and Recieving XML via cURL

162 New Member
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
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. '<?xml version="1.0"?>'
  3. $xml = "<member><name>name</name></member>";
  4. echo $xml;
  5. ?>
  6.  
Array Method - Works great with arrays. I tried with XML as $data, and it no work. Getting it working this way is preferred.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. exec("/usr/bin/curl -m 120 -d \"$xml\" http://www.example.com/index.php -L", $response);
  3. // $response is null
  4. ?>
  5.  
Alternate Method - This way is failing also.
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. $url = "build_xml.php";
  3. $ch = curl_init();    // initialize curl handle
  4. curl_setopt($ch, CURLOPT_URL,$url); // set url to post to
  5. curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
  6. curl_setopt($ch, CURLOPT_TIMEOUT, 4); // times out after 4s
  7. curl_setopt($ch, CURLOPT_POSTFIELDS, $XPost); // add POST fields
  8. $result = curl_exec($ch); // run the whole process
  9. echo $result; //contains response from server 
  10. // NO RESPONSE RECEIVED
  11. ?>
  12.  
Aug 4 '07 #1
3 4032
pbmods
5,821 Recognized Expert Expert
Heya, empiresolutions .

build_xml.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. '<?xml version="1.0"?>'
  3. $xml = "<member><name>name</name></member>";
  4. echo $xml;
  5. ?>
  6.  
In this code, you're not actually outputting the XML header. Is this intentional?

Perhaps you meant to do this instead:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $xml = '
  3. <?xml version="1.0" encoding="utf-8"?>
  4. <member>
  5.     <name>name</name>
  6. </member>';
  7.  
  8. return $xml;
  9. ?>
  10.  
Then in your main code:
Expand|Select|Wrap|Line Numbers
  1. $xml = require('build_xml.php');
  2.  
Aug 4 '07 #2
empiresolutions
162 New Member
problem solved here, http://forums.digitalpoint.com/showt...36#post4004636
Aug 10 '07 #3
pbmods
5,821 Recognized Expert Expert
Heya, empiresolutions .

Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)
Aug 10 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2934
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:
17
3213
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 is the code to send an SMS by http, which works great. Can you help / or do you know a good tutorial / website for php and ssl ??? thanx,
3
6332
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(): http://www.canadiandropshipping.com/hello.php3 Does anyone know why this ssl curl test fails? http://www.canadiandropshipping.com...t/diag_curl.php
4
1616
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 located on a different computer. Or, said differently, I would like to use function oncomp1($integer1, $string1, $string2)
4
12152
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 without the user having to wait. I'm doing this (with fsockopen) by sending an http request to a page that does the time consuming stuff and then immediatly closing, without having read any of the response. This way, I don't have to wait for the...
0
5860
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... http://groups.google.co.uk/group/comp.lang.php/browse_thread/thread/2e052386da903425/b03ec83ac55273a2?lnk=st&q=&rnum=1#b03ec83ac55273a2 Everyone on that post seems to say its to do with the cookie's, yet if infact they had tried this script they would have found that even with the cookies enabled this...
9
4932
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 strReturnData As String = _ System.Text.Encoding.ASCII.GetString(receiveBytes)
0
1520
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" /> <input type="hidden" name="recipient" value="myemail@comcast.net" /> <input type="hidden" name="redirect" value="http://mywebsite.com" /> <input type="hidden" name="subject" value="Topic In Question" />
6
9983
by: lakmarket | last post by:
Hi, I am trying to send some querysting using cURL. This is the working API http://smpp4.routesms.com:8080/bulksms/bulksms?username=xxxxxxx&password=xxxxxxx&type=0&dlr=0&destination=94xxxxxxxxxx&source=testing&message=testmessage. The infomation given by Routesms.com: Port: 2345
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10373
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10177
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10118
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5403
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4074
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.