Example #1
0
 /**
  * @param HttpAdapterInterface $adapter An HTTP adapter.
  * @param string               $endpoint Root URL of the SPARQL knowledge base
  * @param string               $user authenticatd user.     
  * @param string               $user authenticatd password.
  */
 public function __construct(HttpAdapterInterface $adapter, $kbid = null, $secretKey = null, $endpoint = null)
 {
     if (is_null($kbid)) {
         $kbid = 'demo';
     }
     if (is_null($secretKey)) {
         $secretKey = 'demo';
     }
     if (is_null($endpoint)) {
         $endpoint = "https://hub1.linkeddata.center/{$kbid}";
     }
     HttpClient::useIdentity($kbid, $secretKey);
     $this->sparql = new SparqlClient("{$endpoint}/sparql");
     parent::__construct($adapter);
 }
 /**
  * @param HttpAdapterInterface $adapter An HTTP adapter.
  * @param string               $locale  A locale (optional).
  */
 public function __construct(HttpAdapterInterface $adapter, $kbid = null, $secretKey = null, $endpoint = null)
 {
     parent::__construct($adapter, static::ROOT_URL, 'it_IT');
     if (is_null($kbid)) {
         $kbid = 'demo';
     }
     if (is_null($secretKey)) {
         $secretKey = 'demo';
     }
     if (is_null($endpoint)) {
         $endpoint = "https://hub1.linkeddata.center/{$kbid}";
     }
     HttpClient::useIdentity($kbid, $secretKey);
     $this->sparql = new SparqlClient("{$endpoint}/sparql");
     $this->factory = new AddressFactory();
 }
 public function get()
 {
     // sanitize request input
     $username = filter_input(INPUT_GET, 'username', FILTER_SANITIZE_STRING);
     $password = filter_input(INPUT_GET, 'password', FILTER_SANITIZE_STRING);
     $endpoint = filter_input(INPUT_GET, 'endpoint', FILTER_SANITIZE_URL);
     $query = filter_input(INPUT_GET, 'query', FILTER_UNSAFE_RAW);
     // prepare request content model
     if ($endpoint && $query) {
         HttpClient::useIdentity($username, $password);
         $sparql = new SparqlClient($endpoint);
         $result = $sparql->query($query);
     } else {
         $result = new Graph($_SERVER['REQUEST_URI']);
     }
     return self::stateTransfer($result, WebLink::factory('sparqlForm.php?' . http_build_query($_GET))->rel('edit'));
 }