Jump to content

API Error


Recommended Posts

I am having an error doing an ajax call to this REST point this is the point http://api.ingrub.com/v2/locations/32.6724822/-116.9447485

 

this is the ajax function with jquery

 $.ajax({
        url: 'http://api.ingrub.com/v2/locations/32.6724822/-116.9447485',
        type:  "GET",
        beforeSend: function(xhr){xhr.setRequestHeader('auth', 'b26d5f5881f8a030e2d33085a65ad15e');},
        dataType: 'json',
        success: function(response) {
      
        }
      });

I get a 404 error Not Found. Any ideas why this might be happening? 

Link to comment
https://forums.phpfreaks.com/topic/288665-api-error/
Share on other sites

I am not getting any error log 

this are the latest one

 

/home/ingrub/public_html/api/v2/index.php on line 53
[05-May-2014 04:31:16 UTC] PHP Fatal error:  Call to a member function get() on a non-object in /home/ingrub/public_html/api/v2/index.php on line 53
[05-May-2014 04:32:13 UTC] PHP Fatal error:  Call to a member function post() on a non-object in /home/ingrub/public_html/api/v2/index.php on line 53
[05-May-2014 05:39:50 UTC] PHP Parse error:  syntax error, unexpected T_VARIABLE in /home/ingrub/public_html/api/v2/index.php on line 67
 
its weird because when i use it in my rest application to call the info it works fine, but not via ajax so i have a feeling something is wrong with the jquery function this is the console log error from the browser
 
Failed to load resource: the server responded with a status of 404 (Not Found) http://api.ingrub.com/v2/locations/32.6724822/-116.9447485
XMLHttpRequest cannot load http://api.ingrub.com/v2/locations/32.6724822/-116.9447485. Invalid HTTP status code 404 index.html:1
Link to comment
https://forums.phpfreaks.com/topic/288665-api-error/#findComment-1480454
Share on other sites

When i was developing the API i had problems with the apache_request_headers so i added the following function to fix the issue 

if( !function_exists('apache_request_headers') ) {
    function apache_request_headers() {
        $arh = array();
        $rx_http = '/\AHTTP_/';

        foreach($_SERVER as $key => $val) {
            if( preg_match($rx_http, $key) ) {
                $arh_key = preg_replace($rx_http, '', $key);
                $rx_matches = array();
           // do some nasty string manipulations to restore the original letter case
           // this should work in most cases
                $rx_matches = explode('_', $arh_key);

                if( count($rx_matches) > 0 and strlen($arh_key) > 2 ) {
                    foreach($rx_matches as $ak_key => $ak_val) {
                        $rx_matches[$ak_key] = ucfirst($ak_val);
                    }

                    $arh_key = implode('-', $rx_matches);
                }

                $arh[$arh_key] = $val;
            }
        }

        return( $arh );
    }
}

I believe this is the problem. i am going to try to change environment see if i get a different result 

Link to comment
https://forums.phpfreaks.com/topic/288665-api-error/#findComment-1480535
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.