Fetching latest commit…
Cannot retrieve the latest commit at this time.
|Failed to load latest commit information.|
ABOUT: This is a C cgi that "mirrors" web services available via HTTP POST or GET. The reason you might want to do this is to access off-site JSON data sources from scripts via JSONP. Because the trick behind JSONP is dynamically adding "<script>" nodes to the DOM with the DOM API, it's intrinsically limited to external scripts available with an HTTP "GET." This CGI lets you send HTTP POST data to off-site URLs, and retrieve the result, with an HTTP GET - it 'tunnels' GET to POST. OVERVIEW: jsonptunnel.cgi itself looks for four GET variables, two of which are required: REQUIRED: 1. extURL - the URL to GET or POST to. 2. extMethod - the HTTP method to use when fetching the URL. OPTIONAL: 1. extCallback - wraps the off-site output with a function named this parameter, taking the returned data as its only parameter. Many JSONP web services provide their own 'callback' parameter; if they don't, you can use this. NOT IMPLEMENTED: 2. extCache - if this is set to anything, look for a cached version of the query before fetching. This feature is not yet implemented. EXAMPLE: http://yoursite.com/cgi-bin/jsonptunnel.cgi?extURL=http:// somewhereelse.com/data/post&extMethod=POST&someThing=yo& somethingElse=rofl EXPLANATION: jsonptunnel sends any variables you specify in the query string other than the ext* variables to the target URL. LIVE EXAMPLE: http://ubergibson.com/~alan/calc/ This is a page using Mootools with the JsonP extension from clientcide. It's an example of how to tunnel a POST request across domains to a simple web service that adds two numbers, and display the result. QUICKSTART: 1. make get-cgic 2. make 3. copy the created jsonptunnel.cgi to your cgi-bin (or equivalent). DEPENDENCIES: 1. libcurl 2. libcgic - download automatically with 'make get-cgic' command. jsonptunnel requires libcurl and libcgic. libcurl is pretty common, libcgic is not. The 'make get-cgic' command downloads cgic into the current directory and a subsequent make command will build the library and link against it.