Guest User

Untitled

a guest
Aug 22nd, 2012
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // E-Hentai JSON API v1  ---------------------
  2. /*
  3.  
  4.     URL: http://g.e-hentai.org/api.php
  5.     CORS: Enabled ( http://enable-cors.org/ )
  6.     Request: JSON data encoded in UTF-8
  7.     Response: JSON data encoded in UTF-8, gzipped
  8.     Current features:
  9.         * Gallery token lookup with page URL & gallery ID
  10.         * Gallery metadata lookup with gallery IDs & tokens
  11. */
  12.  
  13. // Example API JSON request & code (token list) ----------------------
  14.  
  15. var token_request, token_response;
  16.  
  17. token_request = {
  18.     "method": "gtoken",
  19.     "pagelist": [
  20.         [519366,"9ea977f01f",7],
  21.         [519316,"c470d6f268",6],
  22.         [519313,"867b2e6664",8]
  23.     ]
  24. };
  25.  
  26. var xhr_token = new XMLHttpRequest();
  27. xhr_token.open('POST', 'http://g.e-hentai.org/api.php');
  28. xhr_token.setRequestHeader('Content-Type', 'application/json');
  29. xhr_token.onreadystatechange = function () {
  30.     if(xhr_token.readyState === 4 && xhr_token.status === 200) {
  31.         token_response = JSON.parse(xhr_token.responseText);
  32.     }
  33. }
  34.  
  35. xhr_token.send(JSON.stringify(token_request));
  36.  
  37. // (Formatted) JSON response from the API (token list) ---------------
  38.  
  39. {
  40.    "tokenlist":[
  41.       {
  42.          "gid":519366,
  43.          "error":"File not found"
  44.       },
  45.       {
  46.          "gid":519316,
  47.          "token":"1c4564cf7c"
  48.       },
  49.       {
  50.          "gid":519313,
  51.          "token":"41610cd7ff"
  52.       }
  53.    ]
  54. }
  55.  
  56. // Example API JSON request & code (gallery metadata) ------------------------
  57.  
  58. var gid_request, gid_response;
  59.  
  60. gid_request = {
  61.     "method": "gdata",
  62.     "gidlist": [
  63.         [519325,"20f88fa1cd"],
  64.         [519316,"1c4564cf7c"],
  65.         [519313,"41610cd7ff"]
  66.     ]
  67. };
  68.  
  69. var xhr_gid = new XMLHttpRequest();
  70. xhr_gid.open('POST', 'http://g.e-hentai.org/api.php');
  71. xhr_gid.setRequestHeader('Content-Type', 'application/json');
  72.  
  73. xhr_gid.onreadystatechange = function () {
  74.     if (xhr_gid.readyState === 4 && xhr_gid.status === 200) {
  75.         gid_response = JSON.parse(xhr_gid.responseText));
  76.     }
  77. }
  78.  
  79. xhr_gid.send(JSON.stringify(gid_request));
  80.  
  81. // (Formatted) JSON response from the API (gallery metadata) -----------------
  82.  
  83. {
  84.    "gmetadata":[
  85.       {
  86.          "gid":519325,
  87.          "error":"Key missing, or incorrect key provided."
  88.       },
  89.       {
  90.          "gid":519316,
  91.          "token":"1c4564cf7c",
  92.          "archiver_key":"373790--0ebe43b7e0195329d358c0c1e2091393b65875bb",
  93.          "title":"(C82) [Itou Life] Courteous Utsuho (Touhou Project) (ENG)",
  94.          "title_jpn":"(C82) [伊東ライフ] ねんごろうつほ (東方Project)",
  95.          "category":"Doujinshi",
  96.          "thumb":"http://gt0.ehgt.org/84/ac/84ac5aea499217c366fc7a68fd4092d23c3eb0e2-800167-1407-2000-jpg_l.jpg",
  97.          "uploader":"bobby tod",
  98.          "posted":"1345454172",
  99.          "filecount":"23",
  100.          "filesize":22650578,
  101.          "expunged":false,
  102.          "rating":"4.75",
  103.          "torrentcount":"1",
  104.          "tags":[
  105.             "itou life",
  106.             "english",
  107.             "touhou project",
  108.             "translated",
  109.             "big breasts",
  110.             "utsuho reiuji",
  111.             "c82",
  112.             "x-ray"
  113.          ]
  114.       },
  115.       {
  116.          "gid":519313,
  117.          "token":"41610cd7ff",
  118.          "archiver_key":"373790--6240c1d5e730e8f38364021c9ad0d6397a63683f",
  119.          "title":"(C82) [Shadow Sorceress Communication Protocol (Hiten Onee-Ryuu)] Sugoku Amai Onegai (Sword Art Online) [English]",
  120.          "title_jpn":"(C82) [影法師通訊協定 (飛天御姉流)] スゴクアマイオネガイ (ソードアート・オンライン)",
  121.          "category":"Doujinshi",
  122.          "thumb":"http://gt2.ehgt.org/a4/0d/a40d00dba45663fbc752162d8060c3225da59f71-532312-1045-1500-jpg_l.jpg",
  123.          "uploader":"woootskie",
  124.          "posted":"1345453165",
  125.          "filecount":"23",
  126.          "filesize":13841204,
  127.          "expunged":false,
  128.          "rating":"4.74",
  129.          "torrentcount":"1",
  130.          "tags":[
  131.             "sword art online",
  132.             "english",
  133.             "shadow sorceress communication protocol",
  134.             "translated",
  135.             "hiten onee-ryuu",
  136.             "asuna yuuki",
  137.             "c82"
  138.          ]
  139.       }
  140.    ]
  141. }
  142.  
  143. // --------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment