api and proxy

Spencer's Avatar

Spencer

25 Mar, 2011 06:58 PM

I'm implementing access to seeclickflix data vai an ajax app and am seeing some unexpected behavior from the API. Since I'm accessing from javascript, and you don't seem to support jsonp, I need to route my requests through a proxy. This is where I'm seeing the unexpected behavior.

This is my test API query. The area described is downtown San Francisco.
http://seeclickfix.com/api/issues.json?&lat=37.783251&lng=-...

Pasting this URL into a desktop browser causes an expected response - a bunch of items in San Francisco returned in json.

Pasting this URL into a desktop browser pointed at an apache reverse proxy server (used for other 3rd party apis routinely by us) causes the browser to complain of circular redirects. [this emulates a possible ajax solution for us]

Pasting this URL into a desktop browser pointed at a PHP script that then CURLs to your server causes a json response, but the points returned are distributed all over the USA. [this also emulates a possible ajax solution for us]

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);

Retrieving from the URL with wget from a linux machine causes an html page to be returned.

We, of course, need to be able to get that good San Francisco json response we're seeing from a clean browser based request via a reverse proxy'd request since we're requesting from a javascript app.

Any advice?

Thanks,
Spencer

  1. 2 Posted by Kam on 25 Mar, 2011 07:51 PM

    Kam's Avatar

    Spencer,

    It looks like there may be an extra '&' after the '?' in the parameters. My guess is you are getting different client behavior because they handle the parameter parsing differently.

    Let me know if that helps. Cheers.
    -Kam

  2. 3 Posted by Spencer on 25 Mar, 2011 09:33 PM

    Spencer's Avatar

    That is an embarrassing oversight, but fixing it does not change the behaviors I described in my original message.

  3. 4 Posted by Kam on 25 Mar, 2011 09:50 PM

    Kam's Avatar

    I'm wondering if the user agent on the proxy is getting picked up as a crawler. Would you submit again through each client with a unique token so I can grep our logs to see whats happening?

    example:
    zzclientzz=browser
    zzclientzz=proxy
    zzclientzz=php

    Sorry for the hassle.
    -Kam

  4. 5 Posted by Spencer on 25 Mar, 2011 10:04 PM

    Spencer's Avatar

    Three transactions sent with param &testforkam=

  5. 6 Posted by Spencer on 25 Mar, 2011 10:05 PM

    Spencer's Avatar

    param is actually "&pathforkam=..."

  6. 7 Posted by Kam on 29 Mar, 2011 02:01 PM

    Kam's Avatar

    Sorry, wrote this up last night but didn't hit submit.

    Interesting ... So I see the direct and apachereverseproxy in the logs. I don't see the php requests at all in any log.

    The direct is getting a 200 response and the apachereverseproxy is getting a series of 302 responses from our server. I think the redirects are a bug for us. I will research why nginx is generating those. Is there anyway you can grab the location you are getting redirected to?

    Thanks.
    -Kam

    -Kam

  7. 8 Posted by Spencer on 29 Mar, 2011 05:44 PM

    Spencer's Avatar

    Thanks Kam. I'm switching to your new jsonp interface, which is working like a charm and is my preferred solution over a reverse proxy anyway.

    I've sent you a direct email with details of the redirects coming from your site with an apache reverse proxy in the middle. It appears that your sever is trying to set a cookie and change the domain in the redirect.

    I appreciate your quick response and the great support from the entire team!

  8. Jane Jacobs closed this discussion on 02 Apr, 2011 02:39 PM.

Comments are currently closed for this discussion. You can start a new one.