469,328 Members | 1,251 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,328 developers. It's quick & easy.

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 6888
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

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 suresh191 | last post: by
reply views Thread by Purva khokhar | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.