olud Posted April 30, 2011 Share Posted April 30, 2011 I am using the code below to query a url. It should return the response in xml bu all i get is a string back. $url = 'https://services.example.org/webservices/xget.php?ProductIDValue='.$_GET['pid'].'&ProductIDType=01&ONIXRecordFormat=03&ClientID='.$GLOBALS['user'].'&ClientPassword='.$GLOBALS['pass']; $r= new HttpRequest($url, HttpRequest::METH_GET); $r->send () ; echo $r->getResponseBody() ; 1. How can i get the response as xml 2. How can i display the response on my web page Thanks a lot for your help Link to comment https://forums.phpfreaks.com/topic/235194-php-get-request-and-responceplease-help/ Share on other sites More sharing options...
fugix Posted April 30, 2011 Share Posted April 30, 2011 this is because the return type of this echo $r->getResponseBody() ; is a string... try echo $r->getBodyDocument() ; Link to comment https://forums.phpfreaks.com/topic/235194-php-get-request-and-responceplease-help/#findComment-1208669 Share on other sites More sharing options...
olud Posted April 30, 2011 Author Share Posted April 30, 2011 Thanks for replying fugix. I am new at php , can you tell me how to get an xml response?. Thanks Link to comment https://forums.phpfreaks.com/topic/235194-php-get-request-and-responceplease-help/#findComment-1208671 Share on other sites More sharing options...
fugix Posted April 30, 2011 Share Posted April 30, 2011 try what I have suggested and let me know what you receive Link to comment https://forums.phpfreaks.com/topic/235194-php-get-request-and-responceplease-help/#findComment-1208672 Share on other sites More sharing options...
olud Posted April 30, 2011 Author Share Posted April 30, 2011 Thanks, i tried that and got this error; Fatal error: Call to undefined method HttpRequest::getBodyDocument() in C:\inetpub\wwwroot\.... Link to comment https://forums.phpfreaks.com/topic/235194-php-get-request-and-responceplease-help/#findComment-1208689 Share on other sites More sharing options...
fugix Posted April 30, 2011 Share Posted April 30, 2011 yes that was my mistake...im looking into it now. Link to comment https://forums.phpfreaks.com/topic/235194-php-get-request-and-responceplease-help/#findComment-1208691 Share on other sites More sharing options...
olud Posted April 30, 2011 Author Share Posted April 30, 2011 Thanks Bro Link to comment https://forums.phpfreaks.com/topic/235194-php-get-request-and-responceplease-help/#findComment-1208701 Share on other sites More sharing options...
fugix Posted April 30, 2011 Share Posted April 30, 2011 echo $r->getResponseXML() ; Link to comment https://forums.phpfreaks.com/topic/235194-php-get-request-and-responceplease-help/#findComment-1208704 Share on other sites More sharing options...
olud Posted April 30, 2011 Author Share Posted April 30, 2011 Thanks fugix for your help so far but i am still getting the error; Fatal error: Call to undefined method HttpRequest::getResponseXML() in C:\inetpub\wwwroot\.... Link to comment https://forums.phpfreaks.com/topic/235194-php-get-request-and-responceplease-help/#findComment-1208706 Share on other sites More sharing options...
fugix Posted April 30, 2011 Share Posted April 30, 2011 echo $r->getResponseBody()->asXML() ; Link to comment https://forums.phpfreaks.com/topic/235194-php-get-request-and-responceplease-help/#findComment-1208710 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.