Ejemplo n.º 1
0
Archivo: index.php Proyecto: bruno/twfy
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();
}
Ejemplo n.º 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>
<? 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();
}
Ejemplo n.º 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 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();
}
Ejemplo n.º 4
0
<?php

include_once '../../includes/easyparliament/init.php';
include_once '../../includes/postcode.inc';
include_once 'api_functions.php';
include_once '../../../../phplib/auth.php';
$a = auth_ab64_encode(random_bytes(32));
$this_page = 'api_key';
$PAGE->page_start();
$PAGE->stripe_start();
api_key_current_message();
echo '<p>TheyWorkForYou API calls require a key, so that we can monitor usage
of the service, and provide usage stats to you.';
if ($THEUSER->loggedin()) {
    if (get_http_var('create_key')) {
        create_key(get_http_var('commercial'), get_http_var('reason'));
    }
    $db = new ParlDB();
    $q = $db->query('SELECT api_key, commercial, created, reason FROM api_key WHERE user_id=' . $THEUSER->user_id());
    $keys = array();
    for ($i = 0; $i < $q->rows(); $i++) {
        $keys[] = array($q->field($i, 'api_key'), $q->field($i, 'commercial'), $q->field($i, 'created'), $q->field($i, 'reason'));
    }
    if ($keys) {
        echo '<h3>Your keys</h3> <ul>';
    }
    foreach ($keys as $keyarr) {
        list($key, $commercial, $created, $reason) = $keyarr;
        echo '<li><span style="font-size:200%">' . $key . '</span><br><span style="color: #666666;">';
        if ($commercial == 1) {
            echo 'Commercial key';
Ejemplo n.º 5
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>

<ol style="font-size:130%">
<li><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>

<?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="<?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>
<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 the UK OpenAustralia public developer mailing list</a>
to discuss things.</p>

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