<?php

function requestView($viewUrl, $key){
	//viewURL example: "auth/_design/chkauth/_view/authv1/"
	$key = json_encode($key);
	require_once('vendor/autoload.php');
	$url = "http://127.0.0.1:5984/"; // edit this line!  Put your URL here

	try {
		$client = new \GuzzleHttp\Client(["base_uri" => $url]);
		$response = $client->request("GET",$viewUrl . "?key=" . $key);
		if($response->getStatusCode() == 200) {
			return(json_decode($response->getBody(),true));
		}
	} catch (\GuzzleHttp\ExceptionRequestException $e) {
		// couldn't connect
		return false;
	} catch (\GuzzleHttp\ExceptionClientException $e) {
		// 400-class error
		return false;
	} catch (\GuzzleHttp\ExceptionServerException $e) {
		// 500-class error
		return false;
	}
}

?>