472,129 Members | 1,639 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,129 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";
  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>";
  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();
  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 6968
Well pear isn't installed so that kinda sucks. Any other way to post an XML request?
Feb 4 '08 #2
2,057 Expert 2GB
Not sure why you can't just install/enable pear. Anyways:
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 :


$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'>

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

Feb 5 '08 #4
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
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

Post your reply

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

Similar topics

3 posts views Thread by Sandro Dentella | last post: by
1 post views Thread by DJ Majestik | last post: by
2 posts views Thread by Alan Prescott | last post: by
5 posts views Thread by Jim Michaels | last post: by
reply views Thread by bwhitehd | last post: by
1 post views Thread by IchBin | last post: by
reply views Thread by Nichu | last post: by
1 post views Thread by IchBin | last post: by
2 posts views Thread by daralthus | last post: by
reply views Thread by leo001 | last post: by

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.