Beispiel #1
0
function api_front_page($error = '')
{
    global $methods;
    page_header('API');
    ?>
<div class="main">
<h2>Journa<i>listed</i> API - Overview</h2>

<p>All requests take a number of parameters. <em>output</em> is optional, and defaults to <kbd>js</kbd>.</p>

<p align="center"><code><?php 
    print OPTION_BASE_URL;
    ?>
/api/<em>function</em>?output=<em>output</em>&amp;<em>other_variables</em></code></p>

<p><strong>The current API is still in flux and subject to change and improvement!</strong>
if this is likely to cause problems for you, please let us know so we can coordinate!</p>

<h3>Outputs</h3>
<p>The <em>output</em> argument can take any of the following values:
<ul>
<li><strong>xml</strong></li>
<li><strong>php</strong>. Serialized PHP, that can be turned back into useful information with the unserialize() command. Quite useful in Python as well, using <a href="http://hurring.com/code/python/serialize/">PHPUnserialize</a>.</li>
<li><strong>js</strong>. A JavaScript object. You can provide a callback
function with the <em>callback</em> variable, and then that function will be
called with the data as its argument.</li>
<li><strong>rabx</strong>. "RPC over Anything But XML".</li>
</ul>

<p>All text is encoded as UTF-8.</p>

<h3>Errors</h3>

<p>
Upon any sort of error, a non-zero <code>status</code> will be returned,
along with an <code>error</code> field containing a human-readable error message.
<ul>
<li>
in XML:<pre><code>
  &lt;jl&gt;
    &lt;status&gt;-1&lt;/status&gt;
    &lt;error&gt;Too many fish&lt;/error&gt;
  &lt;/jl&gt;

</code></pre>
</li>
<li>in JS: <code>{"status":-1,"error":"Too many fish"}</code></li>
<li>in PHP and RABX: a serialised array containing <code>status</code> and <code>error</code></li>
</ul>
</p>


</div>
<div class="sidebar">
<?php 
    api_sidebar();
    ?>
</div>
<?php 
    page_footer();
}
Beispiel #2
0
function api_front_page($error = '')
{
    global $PAGE, $methods, $this_page, $THEUSER;
    $this_page = 'api_front';
    $PAGE->page_start();
    $PAGE->stripe_start();
    if ($error) {
        print "<p style='color: #cc0000'>{$error}</p>";
    }
    ?>
<p>Welcome to OpenAustralia's API section, where you can learn how to query our database for information.</p>

<h3>Overview</h3>

<ol style="font-size:130%">
<li>
<?php 
    if ($THEUSER->loggedin()) {
        ?>
<a href="key">Get an API key (or view stats of existing keys)</a>.
<?php 
    } else {
        ?>
<a href="key">Get an API key</a>.
<?php 
    }
    ?>
<li>All requests are made by GETting a particular URL with a number of parameters. <em>key</em> is required;
<em>output</em> is optional, and defaults to <kbd>js</kbd>.
</ol>

<p align="center"><strong>http://www.openaustralia.org/api/<em>function</em>?key=<em>key</em>&amp;output=<em>output</em>&amp;<em>other_variables</em></strong></p>

<?php 
    api_key_current_message();
    ?>

<p>The current version of the API is <em>1.0.0</em>. If we make changes to the
API functions, we'll increase the version number and make it an argument so you
can still use the old version.</p>

<table>
<tr valign="top">
<td width="60%">

<h3>Outputs</h3>
<p>The <em>output</em> argument can take any of the following values:
<ul>
<li><strong>xml</strong>. XML. The root element is result.</li>
<li><strong>php</strong>. Serialized PHP, that can be turned back into useful information with the unserialize() command. Quite useful in Python as well, using <a href="http://hurring.com/code/python/serialize/">PHPUnserialize</a>.</li>
<li><strong>js</strong>. A JavaScript object. You can provide a callback
function with the <em>callback</em> variable, and then that function will be
called with the data as its argument.</li>
<li><strong>rabx</strong>. "RPC over Anything But XML".</li>
</ul>

</td><td>

<h3>Errors</h3>

<p>If there's an error, either in the arguments provided or in trying to perform the request,
this is returned as a top-level error string, ie. in XML it returns
<code>&lt;result&gt;&lt;error&gt;ERROR&lt;/error&gt;&lt;/result&gt;</code>;
in JS <code>{"error":"ERROR"}</code>;
and in PHP and RABX a serialised array containing one entry with key <code>error</code>.

</td></tr></table>

<h3>Licensing</h3>

<p>To use parliamentary material yourself (that's data returned from
getDebates and getHansard), which is Copyright Commonwealth of Australia, you will need to obtain permission to republish it. When we sought permission, we were told that the material is "considered in the public domain". We're not quite sure what that means so you best check for yourself.</p>

<p>Our own data - lists of members of the House of Representatives, Senators, electoral divisions and so on - is available
under the <a href="http://creativecommons.org/licenses/by-sa/2.5/">Creative
Commons Attribution-ShareAlike license version 2.5</a>.</p>

<p>Low volume, non-commercial use of the API service itself is free. Please
<a href="/contact">contact us</a> for commercial use, or if you are about
to use the service on a large scale.</p>

<h3>Bindings</h3>

<p>In adapting the API of TheyWorkForYou to OpenAustralia we've had to make a number of modifications which means that the language bindings developed for the <a href="http://theyworkforyou.com/api">TheyWorkForYou API</a> won't directly work with the OpenAustralia API. If anyone wishes to adapt them or write new bindings, please
do so, let us know and we'll link to it here. You might want to join the OpenAustralia development mailing list
to discuss things.</p>

<?php 
    $sidebar = api_sidebar();
    $PAGE->stripe_end(array($sidebar));
    $PAGE->page_end();
}
Beispiel #3
0
function api_front_page($error = '') {
	global $PAGE, $methods, $this_page, $THEUSER;
	$this_page = 'api_front';
	$PAGE->page_start();
	$PAGE->stripe_start();
	if ($error) {
		print "<p style='color: #cc0000'>$error</p>";
	}
?>
<p>Welcome to OpenAustralia's API section, where you can learn how to query our database for information.</p>

<h3>Overview</h3>

<ol style="font-size:130%">
<li>
<? if ($THEUSER->loggedin()) { ?>
<a href="key">Get an API key (or view stats of existing keys)</a>.
<? } else { ?>
<a href="key">Get an API key</a>.
<? } ?>
<li>All requests are made by GETting a particular URL with a number of parameters. <em>key</em> is required;
<em>output</em> is optional, and defaults to <kbd>js</kbd>.
</ol>

<p align="center"><strong>http://www.openaustralia.org/api/<em>function</em>?key=<em>key</em>&amp;output=<em>output</em>&amp;<em>other_variables</em></strong></p>

<? api_key_current_message(); ?>

<p>The current version of the API is <em>1.0.0</em>. If we make changes to the
API functions, we'll increase the version number and make it an argument so you
can still use the old version.</p>

<table>
<tr valign="top">
<td width="60%">

<h3>Outputs</h3>
<p>The <em>output</em> argument can take any of the following values:
<ul>
<li><strong>xml</strong>. XML. The root element is result.</li>
<li><strong>php</strong>. Serialized PHP, that can be turned back into useful information with the unserialize() command. Quite useful in Python as well, using <a href="http://hurring.com/code/python/serialize/">PHPUnserialize</a>.</li>
<li><strong>js</strong>. A JavaScript object. You can provide a callback
function with the <em>callback</em> variable, and then that function will be
called with the data as its argument.</li>
<li><strong>rabx</strong>. "RPC over Anything But XML".</li>
</ul>

</td><td>

<h3>Errors</h3>

<p>If there's an error, either in the arguments provided or in trying to perform the request,
this is returned as a top-level error string, ie. in XML it returns
<code>&lt;result&gt;&lt;error&gt;ERROR&lt;/error&gt;&lt;/result&gt;</code>;
in JS <code>{"error":"ERROR"}</code>;
and in PHP and RABX a serialised array containing one entry with key <code>error</code>.

</td></tr></table>

<h3>Licensing</h3>

<p>
  Parliamentary material (that's data returned from getDebates and
  getHansard), is Copyright Commonwealth of Australia and is
  <a href="http://aph.gov.au/legal/copyright.htm">provided by them</a>
  under a <a href="http://creativecommons.org/licenses/by-nc-nd/3.0/au/">
  Creative Commons 3.0 Attribution-NonCommercial-NoDerivs</a> licence.
</p>

<p>Our own data - lists of members of the House of Representatives, Senators, electoral divisions and so on - is available
under the <a href="http://creativecommons.org/licenses/by-sa/2.5/">Creative
Commons Attribution-ShareAlike license version 2.5</a>.</p>

<p>Low volume, non-commercial use of the API service itself is free. Please
<a href="/contact">contact us</a> for commercial use, or if you are about
to use the service on a large scale.</p>

<h3>Bindings</h3>

<ul>
    <li><a href="source/oaapi.phps">PHP source</a> and <a href="source/test.phps">example</a> (thanks to Mark Kinkade for adapting <a href="http://tools.rubenarakelyan.com/twfyapi/">Ruben Arakelyan's TWFY bindings</a>)</li>
    <li><a href="https://github.com/henare/openaustralia-api/">Ruby</a>, by <a href="http://www.acooper.org/">Alex Cooper</a>, updated by <a href="http://www.henaredegan.com/">Henare Degan</a></li>
    <li><a href="http://tools.rubenarakelyan.com/twfyapi/">PHP &amp; ASP.NET</a>, by <a href="http://www.rubenarakelyan.com/">Ruben Arakelyan</a></li>
</ul>

<p>In adapting the API of TheyWorkForYou to OpenAustralia we've had to make a number of modifications which means that the language bindings developed for the <a href="http://theyworkforyou.com/api">TheyWorkForYou API</a> won't directly work with the OpenAustralia API. If anyone wishes to adapt them or write new bindings, please
do so, let us know and we'll link to it here. You might want to <a href="http://groups.google.com/group/openaustralia-dev">join the OpenAustralia community mailing list</a>
to discuss things.</p>

<h3>Examples</h3>

<ul>
<li><a href="http://code.google.com/p/poli-press/">PoliPress</a> is a <a href="http://www.wordpress.org/">WordPress</a> plugin that lets you quote members of parliament and search the Australian Hansard from within your WordPress blog.</li>
<li><a href="https://github.com/henare/oa4wp/">OpenAustralia for WordPress</a> is another WordPress plugin. It displays your MP's most recent speeches on your blog.</li>
</ul>

<?
	$sidebar = api_sidebar();
	$PAGE->stripe_end(array($sidebar));
	$PAGE->page_end();
}
Beispiel #4
0
        $q = $db->query('SELECT count(*) as count FROM api_stats WHERE api_key="' . $key . '" AND query_time > NOW() - interval 1 month');
        $c = $q->field(0, 'count');
        echo "last month: {$c}";
        echo '</p>';
    }
    if ($keys) {
        echo '</ul>';
    }
    api_key_form();
} else {
    echo ' The key is tied to your TheyWorkForYou account,
so if you don\'t yet have one, please <a href="/user/?pg=join">sign up</a>, then
return here to get a key.</p>';
    echo '<p style="font-size:200%"><strong><a href="/user/login/?ret=/api/key">Sign in</a></strong> (or <a href="/user/?pg=join">sign up</a>) to get an API key.</p>';
}
$sidebar = api_sidebar();
$PAGE->stripe_end(array($sidebar));
$PAGE->page_end();
# ---
function create_key($commercial, $reason, $estimated_usage)
{
    global $THEUSER;
    $key = auth_ab64_encode(urandom_bytes(16));
    $db = new ParlDB();
    if ($commercial == '') {
        $commercial = 0;
    }
    $db->query('INSERT INTO api_key (user_id, api_key, commercial, created, reason, estimated_usage) VALUES
        (:user_id, :key, :commercial, NOW(), :reason, :estimated_usage)', array(':user_id' => $THEUSER->user_id(), ':key' => $key, ':commercial' => $commercial, ':reason' => $reason, ':estimated_usage' => $estimated_usage));
}
function api_key_form()
Beispiel #5
0
function api_front_page($error = '')
{
    global $PAGE, $methods, $this_page, $THEUSER;
    $this_page = 'api_front';
    $PAGE->page_start();
    $PAGE->stripe_start();
    if ($error) {
        print "<p style='color: #cc0000'>{$error}</p>";
    }
    ?>
<p>Welcome to TheyWorkForYou's API section, where you can learn how to query our database for information.</p>

<h3>Overview</h3>

<ol style="font-size:130%">
<li>
<?php 
    if ($THEUSER->loggedin()) {
        ?>
<a href="key">Get an API key (or view stats of existing keys)</a>.
<?php 
    } else {
        ?>
<a href="key">Get an API key</a>.
<?php 
    }
    ?>
<li>All requests are made by GETting a particular URL with a number of parameters. <em>key</em> is required;
<em>output</em> is optional, and defaults to <kbd>js</kbd>.
</ol>

<p align="center"><strong>http://www.theyworkforyou.com/api/<em>function</em>?key=<em>key</em>&amp;output=<em>output</em>&amp;<em>other_variables</em></strong></p>

<?php 
    api_key_current_message();
    ?>

<p>The current version of the API is <em>1.0.0</em>. If we make changes to the
API functions, we'll increase the version number and make it an argument so you
can still use the old version.</p>

<table>
<tr valign="top">
<td width="60%">

<h3>Outputs</h3>
<p>The <em>output</em> argument can take any of the following values:
<ul>
<li><strong>xml</strong>. XML. The root element is twfy.</li>
<li><strong>php</strong>. Serialized PHP, that can be turned back into useful information with the unserialize() command. Quite useful in Python as well, using <a href="http://hurring.com/code/python/serialize/">PHPUnserialize</a>.</li>
<li><strong>js</strong>. A JavaScript object. You can provide a callback
function with the <em>callback</em> variable, and then that function will be
called with the data as its argument.</li>
<li><strong>rabx</strong>. "RPC over Anything But XML".</li>
</ul>

</td><td>

<h3>Errors</h3>

<p>If there's an error, either in the arguments provided or in trying to perform the request,
this is returned as a top-level error string, ie. in XML it returns
<code>&lt;twfy&gt;&lt;error&gt;ERROR&lt;/error&gt;&lt;/twfy&gt;</code>;
in JS <code>{"error":"ERROR"}</code>;
and in PHP and RABX a serialised array containing one entry with key <code>error</code>.

</td></tr></table>

<h3>Licensing</h3>

<p>To use parliamentary material yourself (that's data returned from
getDebates, getWrans, and getWMS), you will need to get a
<a href="http://www.opsi.gov.uk/click-use/parliamentary-licence-information/index.htm">Parliamentary Licence</a> from the Office of Public Sector
Information.

<?php 
    /* All Ordnance Survey data (returned by getGeometry and getBoundary) is
    covered by the <acronym title="Pan-Government Agreement">PGA</acronym>
    under the <a href="http://www.dca.gov.uk/">Department for Constitutional
    Affairs</a>; you will have to get your own licence to re-use them. */
    ?>

Our own data - lists of MPs, Lords, constituencies and so on - is available
under the <a href="http://creativecommons.org/licenses/by-sa/2.5/">Creative
Commons Attribution-ShareAlike license version 2.5</a>.

<p>Low volume, non-commercial use of the API service itself is free. Please
<a href="/contact">contact us</a> for commercial use, or if you are about
to use the service on a large scale.

<h3>Bindings</h3>

<p>These help you interface with the API more easily in a particular language:</p>
<ul>
<li><a href="http://codefluency.com/articles/2006/11/21/tfwy-1-0-0-released/">Ruby</a> (thanks to Bruce Williams and Martin Owen)</li>
<li><a href="http://search.cpan.org/perldoc?WebService::TWFY::API">Perl</a> (thanks to Spiros Denaxas)</li>
<li><a href="http://tools.wackomenace.co.uk/twfyapi/">PHP</a> (thanks to Ruben Arakelyan)</li>
<li><a href="http://code.google.com/p/twfython/">Python</a> (thanks to Paul Doran)</li>
<li><a href="http://tools.wackomenace.co.uk/twfyapi/">ASP.net</a> (thanks to Ruben Arakelyan)</li>
<li><a href="https://sourceforge.net/projects/twfyjavaapi">Java</a> (thanks to Mitch Kent)</li>
</ul>

<p>If anyone wishes to write bindings for the API in any language, please
do so, let us know and we'll link to it here. You might want to
<a href="https://secure.mysociety.org/admin/lists/mailman/listinfo/developers-public">join our public developer mailing list</a>
to discuss things.</p>

<h3>Examples</h3>

<ul>
<li><a href="http://www.dracos.co.uk/work/theyworkforyou/api/postcode/">Postcode to constituency lookup, with no server side code</a> - use this to add constituency or MP lookup to a form on your website.
<li><a href="http://www.dracos.co.uk/work/theyworkforyou/api/map/">Map showing location of all 646 constituencies, with no server side code</a> - example code using JavaScript and Google Maps.
<li><a href="javascript:function foo(r){if(r.twfy.url)window.location=r.twfy.url;};(function(){var s=document.createElement('script');s.setAttribute('src','http://theyworkforyou.com/api/convertURL?key=Gbr9QgCDzHExFzRwPWGAiUJ5&callback=foo&url='+encodeURIComponent(window.location));s.setAttribute('type','text/javascript');document.getElementsByTagName('head')[0].appendChild(s);})()">Hansard prettifier</a> - drag this bookmarklet to your bookmarks bar, or bookmark it. Then if you ever find yourself on the official site, clicking this will try and take you to the equivalent page on TheyWorkForYou. (Tested in IE, Firefox, Opera.)</li>
<li><a href="http://www.dracos.co.uk/work/theyworkforyou/api/fabfarts/">Matthew's MP Fab Farts</a> - every technology has the capacity to be used for fun.
<li><a href="telnet://seagrass.goatchurch.org.uk:646/">Francis' MP Fight telnet text adventure</a> (<s>and <a href="http://caesious.beasts.org/~chris/scripts/mpfight">Chris' web version</a></s>) - battle your way to Sedgefield!
<li><a href="http://www.straw-dogs.co.uk/10/15/your-mp-google-desktop-gadget/">Your MP - Google Desktop Gadget</a> - with GPL source code
</ul>

<?php 
    $sidebar = api_sidebar();
    $PAGE->stripe_end(array($sidebar));
    $PAGE->page_end();
}
Beispiel #6
0
function api_front_page($error = '')
{
    global $PAGE, $methods, $this_page, $THEUSER;
    $this_page = 'api_front';
    $PAGE->page_start();
    $PAGE->stripe_start();
    if ($error) {
        print "<p style='color: #cc0000'>{$error}</p>";
    }
    $em = join('&#64;', array('enquiries', 'mysociety.org'));
    ?>

<h3>Overview</h3>
<p>
    Welcome to TheyWorkForYou's API section. The API (Application Programming
    Interface) is a way of querying our database for information.
</p>
<p>
    To use the API you need <a href="key">an API key</a>, and you may need a
    license from us.
</p>
<p>
    The documentation for each individual API function is linked from this
    page: you can read what each function does, and test it out, without
    needing an API key or to write any code.
</p>

<h3>Terms of usage</h3>
<p>
    Low volume, charitable use of the API is free. This means direct use by
    registered charities, or individuals pursuing a non-profit project on an
    unpaid basis, with a volume of up to 50,000 calls per year. All other use
    requires a licence, as a contribution towards the costs of providing this
    service. Please email us at <a href="mailto:<?php 
    echo $em;
    ?>
"><?php 
    echo $em;
    ?>
</a> if your
    usage is likely to fall into the non-free bracket: <strong>unlicensed users
    may be blocked without warning</strong>.
</p>

<h3>Pricing</h3>
<p>
    &pound;500 per year for up to 50,000 calls (free for charitable usage)<br/>
    &pound;1,000 per year for up to 100,000 calls<br/>
    &pound;2,000 per year for up to 200,000 calls<br/>
    &pound;2,500 per year for up to 300,000 calls<br/>
    &pound;3,000 per year for up to 500,000 calls<br/>
</p>
<p>In addition, we offer a 50% discount on the above rates for charitable usage.</p>

<h3>Credits</h3>
<p>Parliamentary material (that's data returned from getDebates, getWrans, and
getWMS) may be reused under the terms of the
<a href="http://www.parliament.uk/site-information/copyright/">Open Parliament Licence</a>.
Our own data &ndash; lists of MPs, Lords, constituencies and so on &ndash; is
available under the
<a href="http://creativecommons.org/licenses/by-sa/2.5/">Creative Commons
Attribution-ShareAlike license version 2.5</a>.

<p>Please credit us by linking to <a href="http://www.theyworkforyou.com/">TheyWorkForYou</a>
with wording such as "Data service provided by TheyWorkForYou" on the page
where the data is used. This attribution is optional if you've paid for use of
the service.


<h3>Technical documentation</h3>
<p>
    All requests are made by GETting a particular URL with a number of
    parameters. <em>key</em> is required; <em>output</em> is optional, and
    defaults to <kbd>js</kbd>.
</p>
<p align="center">
    <strong>http://www.theyworkforyou.com/api/<em>function</em>?key=<em>key</em>&amp;output=<em>output</em>&amp;<em>other_variables</em></strong>
</p>
<p>
    The current version of the API is <em>1.0.0</em>. If we make changes to
    the API functions, we'll increase the version number and make it an
    argument so you can still use the old version.
</p>

<table>
<tr valign="top">
<td width="60%">

<h3>Outputs</h3>
<p>The <em>output</em> argument can take any of the following values:
<ul>
<li><strong>xml</strong>. XML. The root element is twfy.</li>
<li><strong>php</strong>. Serialized PHP, that can be turned back into useful information with the unserialize() command. Quite useful in Python as well, using <a href="http://hurring.com/code/python/serialize/">PHPUnserialize</a>.</li>
<li><strong>js</strong>. A JavaScript object. You can provide a callback
function with the <em>callback</em> variable, and then that function will be
called with the data as its argument.</li>
<li><strong>rabx</strong>. "RPC over Anything But XML".</li>
</ul>

</td><td>

<h3>Errors</h3>

<p>If there's an error, either in the arguments provided or in trying to perform the request,
this is returned as a top-level error string, ie. in XML it returns
<code>&lt;twfy&gt;&lt;error&gt;ERROR&lt;/error&gt;&lt;/twfy&gt;</code>;
in JS <code>{"error":"ERROR"}</code>;
and in PHP and RABX a serialised array containing one entry with key <code>error</code>.

</td></tr></table>

<h3>Bindings</h3>

<p>These help you interface with the API more easily in a particular language:</p>
<ul>
<li><a href="https://github.com/rubenarakelyan/twfyapi/">ASP.net</a> (thanks to Ruben Arakelyan)</li>
<li><a href="https://github.com/rhinocratic/twfy">Clojure</a> (thanks to Andrew Baxter)</li>
<li><a href="https://github.com/jamtho/twfy">Common Lisp</a> (thanks to James Thompson)</li>
<li><a href="https://github.com/rubenarakelyan/twfyapi/">JavaScript</a> (thanks to Ruben Arakelyan)</li>
<li><a href="https://sourceforge.net/projects/twfyjavaapi">Java</a> (thanks to Mitch Kent)</li>
<li><a href="http://search.cpan.org/perldoc?WebService::TWFY::API">Perl</a> (thanks to Spiros Denaxas)</li>
<li><a href="https://github.com/rubenarakelyan/twfyapi/">PHP</a> (thanks to Ruben Arakelyan)</li>
<li><a href="http://code.google.com/p/twfython/">Python</a> (thanks to Paul Doran)</li>
<li><a href="http://github.com/bruce/twfy">Ruby</a> (thanks to Bruce Williams and Martin Owen)</li>
<li><a href="https://github.com/ifraixedes/node-theyworkforyou-api">Node</a> (thanks to Ivan Fraixedes)</li>
</ul>

<p>If anyone wishes to write bindings for the API in any language, please
do so, let us know and we'll link to it here. You might want to
<a href="https://groups.google.com/a/mysociety.org/forum/#!forum/theyworkforyou">join our mailing list</a>
to discuss things.</p>

<h3>Example</h3>

<ul>
<li><a href="javascript:function foo(r) {if (r.twfy.url)window.location=r.twfy.url;};(function () {var s=document.createElement('script');s.setAttribute('src','http://theyworkforyou.com/api/convertURL?key=Gbr9QgCDzHExFzRwPWGAiUJ5&callback=foo&url='+encodeURIComponent(window.location));s.setAttribute('type','text/javascript');document.getElementsByTagName('head')[0].appendChild(s);})()">Hansard prettifier</a> - drag this bookmarklet to your bookmarks bar, or bookmark it. Then if you ever find yourself on the official site, clicking this will try and take you to the equivalent page on TheyWorkForYou. (Tested in IE, Firefox, Opera.)</li>
</ul>

<?php 
    $sidebar = api_sidebar();
    $PAGE->stripe_end(array($sidebar));
    $PAGE->page_end();
}
Beispiel #7
0
function api_front_page($error = '')
{
    global $PAGE, $methods, $this_page;
    $this_page = 'api_front';
    $PAGE->page_start();
    $PAGE->stripe_start();
    if ($error) {
        print "<p style='color: #cc0000'>{$error}</p>";
    }
    ?>
<p>Welcome to OpenAustralia's API section, where you can learn how to query our database for information.</p>

<h3>Overview</h3>

<p>All requests take a number of parameters. <em>output</em> is optional, and defaults to <kbd>js</kbd>.</p>

<p align="center"><strong>http://www.openaustralia.org/api/<em>function</em>?output=<em>output</em>&<em>other_variables</em></strong></p>

<p>The current version of the API is <em>1.0.0</em>. If we make changes
to the API,
we'll increase the version number and make it an argument so you can still
use the old version.</p>

<h3>Outputs</h3>
<p>The <em>output</em> argument can take any of the following values:
<ul>
<li><strong>xml</strong>. XML. The root element is twfy.</li>
<li><strong>php</strong>. Serialized PHP, that can be turned back into useful information with the unserialize() command. Quite useful in Python as well, using <a href="http://hurring.com/code/python/serialize/">PHPUnserialize</a>.</li>
<li><strong>js</strong>. A JavaScript object. You can provide a callback
function with the <em>callback</em> variable, and then that function will be
called with the data as its argument.</li>
<li><strong>rabx</strong>. "RPC over Anything But XML".</li>
</ul>

<h3>Licensing</h3>

<p>To use parliamentary material yourself (that's data returned from
getDebates, getWrans, and getWMS), you will need to get a
<a href="http://www.opsi.gov.uk/click-use/parliamentary-licence-information/index.htm">Parliamentary Licence</a> from the Office of Public Sector
Information.

<?php 
    /* All Ordnance Survey data (returned by getGeometry and getBoundary) is
    covered by the <acronym title="Pan-Government Agreement">PGA</acronym>
    under the <a href="http://www.dca.gov.uk/">Department for Constitutional
    Affairs</a>; you will have to get your own licence to re-use them. */
    ?>

Our own data - lists of MPs, Lords, constituencies and so on - is available
under the <a href="http://creativecommons.org/licenses/by-sa/2.5/">Creative
Commons Attribution-ShareAlike license version 2.5</a>.

<p>Low volume, non-commercial use of the API service itself is free. Please
<a href="<?php 
    echo WEBPATH;
    ?>
/contact">contact us</a> for commercial use, or if you are about
to use the service on a large scale.

<h3>Bindings</h3>

<p>These help you interface with the API more easily in a particular language:</p>
<ul>
<li><a href="http://codefluency.com/2006/11/21/tfwy-1-0-0-released">Ruby</a> (thanks to Bruce Williams and Martin Owen)</li>
<li><a href="http://search.cpan.org/~sden/WebService-TWFY-API-0.01/lib/WebService/TWFY/API.pm">Perl</a> (thanks to Spiros Denaxas)</li>
</ul>

<p>If anyone wishes to write bindings for the API in any language, please
do so, let us know and we'll link to it here. You might want to
<a href="https://secure.mysociety.org/admin/lists/mailman/listinfo/developers-public">join the UK OpenAustralia public developer mailing list</a>
to discuss things.</p>

<?php 
    $sidebar = api_sidebar();
    $PAGE->stripe_end(array($sidebar));
    $PAGE->page_end();
}