GithubHelp home page GithubHelp logo

alandipert / jsonptunnel Goto Github PK

View Code? Open in Web Editor NEW
11.0 2.0 2.0 136 KB

C (F)CGI for tunneling POST over GET for cross-site JSONP POST requests

Home Page: http://labs.thinkminimo.com/jsonptunnel/

C 100.00%

jsonptunnel's Introduction

ABOUT:

  This is a C fastcgi/cgi that "mirrors" web services available via HTTP POST.

  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 two GET variables, one of which 
  is required:

    REQUIRED PARAMETERS:

      1. extURL - the URL to POST to.

    OPTIONAL PARAMETERS:

      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.

    EXPLANATION:

      jsonptunnel sends any variables you specify in the query
      string other than the ext* variables to the target URL.

    LIVE EXAMPLE:

      http://labs.thinkminimo.com/jsonptunnel/

      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.

COMPILING:

  CGI:

  1. make get-cgic
  2. make cgi
  3. copy jsonptunnel.cgi to your cgi-bin (or equivalent).

  FastCGI:

  1. make get-cgic
  2. make fcgi
  3. Configure your web server to run jsonptunnel.fcgi. See "LIGHTTPD.EXAMPLE.CONF"
     for an example configuration.

  You may have to modify the Makefile variable FCGI_INCLUDE to point 
  to the location of the FastCGI header files on your system.

  CAVEATS:

  To switch between fcgi and cgi builds, 'make clean'
  before running 'make cgi' or 'make fcgi.'

DEPENDENCIES:

  1. libcurl - http://curl.haxx.se/
  2. libcgic - http://www.boutell.com/cgic/ 
               download and patch automatically with 'make get-cgic' command.
  3. FastCGI - http://www.fastcgi.com/

  jsonptunnel requires libcurl, libcgic, and fastcgi.  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.

THANKS:

  I'd like to thank the CURL team, Boutell.com, and the FastCGI guys
  for making such awesome software.

jsonptunnel's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

moneytech

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.