Advertisement
phpface

Untitled

Jul 7th, 2020
1,588
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.46 KB | None | 0 0
  1. function my_query(){
  2.  
  3.     $query = '
  4.         prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
  5.         prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
  6.         prefix owl: <http://www.w3.org/2002/07/owl#>
  7.         prefix xsd: <http://www.w3.org/2001/XMLSchema#>
  8.         prefix sr: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>
  9.         prefix ukhpi: <http://landregistry.data.gov.uk/def/ukhpi/>
  10.         prefix lrppi: <http://landregistry.data.gov.uk/def/ppi/>
  11.         prefix skos: <http://www.w3.org/2004/02/skos/core#>
  12.         prefix lrcommon: <http://landregistry.data.gov.uk/def/common/>
  13.  
  14.         SELECT ?paon ?saon ?street ?town ?county ?postcode ?amount ?date ?category
  15.         WHERE
  16.         {
  17.           VALUES ?postcode {"PL6 8RU"^^xsd:string}
  18.  
  19.           ?addr lrcommon:postcode ?postcode.
  20.  
  21.           ?transx lrppi:propertyAddress ?addr ;
  22.                   lrppi:pricePaid ?amount ;
  23.                   lrppi:transactionDate ?date ;
  24.                   lrppi:transactionCategory/skos:prefLabel ?category.
  25.  
  26.           OPTIONAL {?addr lrcommon:county ?county}
  27.           OPTIONAL {?addr lrcommon:paon ?paon}
  28.           OPTIONAL {?addr lrcommon:saon ?saon}
  29.           OPTIONAL {?addr lrcommon:street ?street}
  30.           OPTIONAL {?addr lrcommon:town ?town}
  31.         }
  32.         ORDER BY ?amount
  33.     ';
  34.  
  35.     $response = wp_remote_post( 'http://landregistry.data.gov.uk/landregistry/query', array(
  36.         'body'  =>  array(
  37.             'query' =>  $query,
  38.             'output'    =>  'json'
  39.         )
  40.     ) );
  41.  
  42.  
  43.     $response = json_decode( wp_remote_retrieve_body( $response ), true );
  44.  
  45.     return $response['results']['bindings'];
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement