Jump to content

Recommended Posts

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:

 

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

Are you on shared hosting? If so chances are you are not allowed to pull data from remote sites using file_get_contents as most shared hosts have that turned off for security reasons. If this is the case they also tend to have cURL enabled, and you can use that to retrieve the data instead (see the php manual by click on cURL for more information on how to do that).

I believe the problem is more to do with the https, however the solution is almost the same

try this

<?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";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //REQUIRED for HTTPS
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$xml = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

//list($version,$status_code,$msg) = explode(' ',$http_response_header[0], 3);
$status_code = $info['http_code']; //replacing previous line

// 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;

Hey it solved the issue thanks a lot.It is even working on shared hosting of yahoo with PHP 4.3.11.

But I'm not able to parse the XML file using simpleXMLElement class.

I guess simpleXMLElement is not for the PHP 4. Is there any other equivalent class to parse

XML in PHP 4.

 

regards,

Ram

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.