473,402 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

PHP - XML Request without PEAR

I've been doing PHP for 6 years now and can write most systems in a few days, but I have never looked into XML much, even though I know I should.

Here is my problem :

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $url = "http://www.e-travelsolution.com/xml/xmlpostreceiver1-0.asmx/ET_SO_HT_001";
  3.  
  4. $data = "<?xml version='1.0' encoding='utf-8' ?>
  5. <Request Type='List' Version='1.0'> {List, Reservation, Content}
  6. <Header>
  7. <Product>Hotel</Product>
  8. <Affiliate_Id>test</Affiliate_Id>
  9. <Request_Id>test".time()."</Request_Id>
  10. <Timestamp>".date("Y-m-d",time())."T".date("H:i:s")."</Timestamp>
  11. <Language>ING</Language>
  12. <Currency>US</Currency>
  13. </Header>
  14. <ArrivalDate></ArrivalDate>
  15. <ReturnDate></ReturnDate>
  16. <Destination></Destination>
  17. <MealPlan></MealPlan>
  18. <Category></Category>
  19. <City></City>
  20. <Hotel_Name></Hotel_Name>
  21. <Max></Max>
  22. <New>No</New>
  23. <Inmediate_Conf>YES</Inmediate_Conf>
  24. <Text>YES</Text>
  25. <Order_Id>".$_GET['order_by']."</Order_Id>
  26. <Order_Di>".$_GET['ascdesc']."</Order_Di>
  27. </Request>";
  28.  
  29. $req =& new HTTP_Request($url);
  30. $req->addHeader("Content-Type", "text/xml");
  31. $req->addHeader("Content-Length", strlen($data));
  32. $req->setMethod(HTTP_REQUEST_METHOD_POST);
  33. $req->addRawPostData($data, true);
  34. $req->sendRequest();
  35. echo $req->getResponseBody();
  36.  
  37. ?>
This gives me : Fatal error: Cannot instantiate non-existent class: http_request in /u/t/travyuc/www.travelyucatan.com/hotels_list.php on line 29

:(

Any help would be appreciated. I am trying to get an XML response from the XML posted submission. Their specific instructions were to post an XML request to generate an XML response.
Feb 4 '08 #1
7 7130
Well pear isn't installed so that kinda sucks. Any other way to post an XML request?
Feb 4 '08 #2
jkmyoung
2,057 Expert 2GB
Not sure why you can't just install/enable pear. Anyways:
http://www.topxml.com/php_xml_rpc/ph...de_request.asp
Feb 4 '08 #3
So, I got the host to install the pear modules i needed, but now i am getting an error instead of a response. Here is the code I have :

[PHP]<?php

$url = "http://www.e-travelsolution.com/xml/xmlpostreceiver1-0.asmx/ET_SO_HT_001";

$data = "<?xml version='1.0' encoding='utf-8' ?>
<Request Type='List' Version='1.0'>
<Header>
<Product>Hotel</Product>
<Affiliate_Id>USERNAME</Affiliate_Id>
<Request_Id>USER".time()."</Request_Id>
<Timestamp>".date("Y-m-d",time())."T".date("H:i:s")."</Timestamp>
<Language>ING</Language>
<Currency>US</Currency>
</Header>
<ArrivalDate>".$_GET['AD']."</ArrivalDate>
<ReturnDate>".$_GET['DD']."</ReturnDate>
<Destination>".$_GET['DEST']."</Destination>
<MealPlan>".$_GET['MP']."</MealPlan>
<Category>".$_GET['CAT']."</Category>
<City>".$_GET['CITY']."</City>
<Hotel_Name>".$_GET['HN']."</Hotel_Name>
<Max>".$_GET['MAX']."</Max>
<New>No</New>
<Inmediate_Conf>YES</Inmediate_Conf>
<Text>YES</Text>
<Order_Id>".$_GET['order_by']."</Order_Id>
<Order_Di>".$_GET['ascdesc']."</Order_Di>
</Request>";

require 'HTTP/Request.php';
$req =& new HTTP_Request($url);
$req->addHeader("Content-Type", "text/xml");
$req->addHeader("Content-Length", strlen($data));
$req->setMethod(HTTP_REQUEST_METHOD_POST);
$req->addRawPostData($data, true);
$req->sendRequest();
echo $req->getResponseBody();

?>[/PHP]
Feb 5 '08 #4
jkmyoung
2,057 Expert 2GB
What is the error? It would help to find the problem.
Feb 6 '08 #5
This is the error :

Expand|Select|Wrap|Line Numbers
  1. Error #0: Pag: www.e-travelsolution.com PEAR HTTP_Request class ( http://pear.php.net/ ) Originado por: .getDataReader  91  Object reference not set to an instance of an object.  IPDMCZ0431MIA
Feb 7 '08 #6
jkmyoung
2,057 Expert 2GB
What version of PHP are you using? Many of these problems are associated with PHP before 4.2
Feb 7 '08 #7
I'm using version 4.2.3.

I know there are earlier versions, but the error seems to be coming from their end. I am at least getting some sort of response. I am just wondering what the error means so maybe I can fix it from my end.
Feb 8 '08 #8

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

Similar topics

3
by: Sandro Dentella | last post by:
I need to use a class to handle mbox files that uses PEAR. Since I'm using Debian (both woody and, I simply apt-get(ed) php4-pear but I can't use it becouse I get the error: Warning: dl():...
1
by: DJ Majestik | last post by:
OK, I am new to the whole PEAR/Smarty templating thing. I am trying to setup my directory structure correctly. If someone could weigh in and see if I have this setup "right", I would appreciate it....
2
by: Alan Prescott | last post by:
I'm running SuSE Linux 9.3, fully up to date running # pear install db responds with ... downloading DB-1.7.6.tgz ... Starting to download DB-1.7.6.tgz (124,807 bytes)...
5
by: Jim Michaels | last post by:
I downloaded a PEAR module, but it came with this XML file and a PHP file. I figure I just include the PHP file somehow, but what do I do with the XML file?
0
by: bwhitehd | last post by:
I'm having a problem installing php. The compile seems to go fine, but when it gets to the install step I get the following errors. Does anyone have an idea of what might be the problem? We...
1
by: IchBin | last post by:
I am new to PHP and I am running on Windoze XP SP 2. Just noticed that the PEAR installed dir structure I have (to DB subdir) is : C:\php5.2\PEAR\pear\DB My registry vars are:...
0
by: Nichu | last post by:
Hello Lately I started to "bravely fight" with Postfix + Squirrelmail everything works great (PHP also :)) but I want to have possibility to change passwords (from MySql database) through the...
1
by: IchBin | last post by:
I remember having problems with pear when I first installed it but got it running some time ago. This is on a windoze XP SP OS. I did not think it was correct because it pointed to...
2
by: daralthus | last post by:
Hello! I would like to ask your help, i have founded a great code here: http://www.jamescaws.co.uk/2008/07/dynamically-count-exit-link-clicks-throughs-using-javascript-php/ but it uses Pear DB...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
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...
1
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...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.