public function execute( $query, $rawData = false ) {

    if ( strlen( $query ) > self::MAX_GET_SIZE ) {
      // big requests go to POST
      $this->method = 'POST';
    }

    $client = new Client();

    $response = $client->request( $this->method, self::SPARQL_ENDPOINT, [
        'query' => [ 
          "query" => $query, 
          "format" => "json",
          "maxQueryTimeMillis" => $this->timeout * 1000
        ]
    ]);

    $status = $response->getStatusCode();

    if ( $status != '200' ) {
      throw new Exception( 'HTTP Error' );
    }

    $result = $response->getBody();

    $data = json_decode( $result, true );
    
    if ( $data === null || $data === false ) {
      throw new Exception( "HTTP request failed, response:\n" .
        substr( $result, 1024 ) );
    }

    return $this->extractData( $data, $rawData );
  }
public function execute( $query, $rawData = false ) {

    if ( strlen( $query ) > self::MAX_GET_SIZE ) {
      // big requests go to POST
      $this->method = 'POST';
    }

    $client = new Client();

    $response = $client->request( $this->method, self::SPARQL_ENDPOINT, [
        'query' => [ 
          "query" => $query, 
          "format" => "json",
          "maxQueryTimeMillis" => $this->timeout * 1000
        ]
    ]);

    $status = $response->getStatusCode();

    if ( $status != '200' ) {
      throw new Exception( 'HTTP Error' );
    }

    $result = $response->getBody();

    $data = json_decode( $result, true );
    
    if ( $data === null || $data === false ) {
      throw new Exception( "HTTP request failed, response:\n" .
        substr( $result, 1024 ) );
    }

    return $this->extractData( $data, $rawData );
  }
public function execute ( $ query , $ rawData = false ) { if ( strlen ( $ query ) > self :: MAX_GET_SIZE ) { // big requests go to POST $ this -> method = 'POST' ; } $ client = new Client ( ) ; $ response = $ client -> request ( $ this -> method , self :: SPARQL_ENDPOINT , [ 'query' => [ "query" => $ query , "format" => "json" , "maxQueryTimeMillis" => $ this -> timeout * 1000 ] ] ) ; $ status = $ response -> getStatusCode ( ) ; if ( $ status != '200' ) { throw new Exception ( 'HTTP Error' ) ; } $ result = $ response -> getBody ( ) ; $ data = json_decode ( $ result , true ) ; if ( $ data === null || $ data === false ) { throw new Exception ( "HTTP request failed, response:\n" . substr ( $ result , 1024 ) ) ; } return $ this -> extractData ( $ data , $ rawData ) ; }
Query SPARQL endpoint

@param string $query
@param bool $rawData Whether to return only values or full data objects

@return array List of results, one row per array element
Each row will contain fields indexed by variable name.
@throws SparqlException
Query SPARQL endpoint