Sourcerer Implementation Notes

From Geohashing
Revision as of 15:14, 8 February 2015 by imported>Sourcerer (PHP Expedition)

Plan of Campaign

My plan is to create some new analysis tools for this wiki. This page might help others to implement their tools.

  1. Get some page content ("Hello World!").
  2. Write some code (perhaps PHP command line code) to do the same. Make sure this does not overload the wiki.
  3. Download different kinds of page.
  4. Do some simple statistics on the downloaded data.
  5. Create reports in wiki markup.
  6. If it works, upload them to the wiki.

Various Downloads

Help Page

http://wiki.xkcd.com/wgh/api.php

JSON Page Content Dump

http://wiki.xkcd.com/wgh/api.php?format=json&action=query&titles=User:Sourcerer&prop=revisions&rvprop=content

List first twenty of Consecutive geohash achievement

http://wiki.xkcd.com/wgh/api.php?action=query&list=categorymembers&cmtitle=Category:Consecutive_geohash_achievement&cmlimit=20

List twenty more of Consecutive geohash achievement

http://wiki.xkcd.com/wgh/api.php?action=query&list=categorymembers&cmtitle=Category:Consecutive_geohash_achievement&cmcontinue=page%7C323030392d30332d31362035322030%7C17773&cmlimit=20

PHP Code - List first twenty of Consecutive geohash achievement - Command line application

<?php
  $html = file_get_contents('http://wiki.xkcd.com/wgh/api.php?action=query&list=categorymembers&cmtitle=Category:Consecutive_geohash_achievement&cmlimit=20');
  echo $html;
?>

PHP Code - As above but use JSON

<?php
  $json     = file_get_contents('http://wiki.xkcd.com/wgh/api.php?action=query&format=json&list=categorymembers&cmtitle=Category:Consecutive_geohash_achievement&cmlimit=20');
  $readable = json_decode($json, true);
  print_r($readable);
?>

PHP Expedition as JSON

<?php
  $json     = file_get_contents('http://wiki.xkcd.com/wgh/api.php?format=json&action=query&titles=2015-02-07_52_1&prop=revisions&rvprop=content');
  $readable = json_decode($json, true);
  print_r($readable);
?>