Page 1 of 1

Couldnot access the xml data from webservice query ?

Posted: Thu Dec 10, 2009 7:35 am
by ram.mahaseth
Hello there,
I'm trying to display the data from record of table I created in
quickbase.com in my webpage.For this I made appropriate query
to quickbase (as suggested in HTTP API Documentation).
It gives response in xml format.I later parse it using simpleXMLElement
and use the required value.
All this works fine when I run the code in local server (I'm using XAMPP, PHP 5.3.0).But it doesnot work when hosted in remote server (PHP 5.2.11).

Here is the code to display xml response:

Code: Select all

 
<?php
//querying the quick base to get xml response to particular report
error_reporting(E_ALL);
echo "<pre>";
$request =  "https://www.quickbase.com/db/bexiahv4m?act=API_DoQuery&ticket=5_bgstwfekp_byrjk4_b_djxbedds8y689c6beqiurhnr54_b737vy85rv2ge_&apptoken=d75hx9nbmacp3jc7si8ezcdb9wgi&qid=7";
$xml = file_get_contents($request);
 
list($version,$status_code,$msg) = explode(' ',$http_response_header[0], 3);
 
// Check the HTTP Status code
switch($status_code) {
    case 200:
        // Success
        break;
    case 503:
        die('Your call to quickbase failed and returned an HTTP status of 503. That means: Service unavailable. An internal problem prevented us from returning data to you.');
        break;
    case 403:
        die('Your call to  quickbase failed and returned an HTTP status of 403. That means: Forbidden. You do not have permission to access this resource, or are over your rate limit.');
        break;
    case 400:
        // You may want to fall through here and read the specific XML error
        die('Your call to  quickbase failed and returned an HTTP status of 400. That means:  Bad request. The parameters passed to the service did not match as expected. The exact error is returned in the XML response.');
        break;
    default:
        die('Your call to  quickbase returned an unexpected HTTP status of:'.$status_code);
}
 
 
$career=htmlspecialchars($xml, ENT_QUOTES);
echo $career;
 
It works good in local server.
But it displays "Your call to quickbase returned an unexpected HTTP status of:" when hosted in remote server.
I've been struggling past few days.But could not find out the reason behind it.
Please anybody help me out.

Thanks in advance