Beispiel #1
0
        $requestUrl .= "?key={$apiKey}";
    }
}
//act as transparent proxy until JS lib can make requests directly to api
$requestMethod = $_SERVER['REQUEST_METHOD'];
//raw body of the request
$rawbody = @file_get_contents('php://input');
$relevantHeaders = array("If-Modified-Since", "If-Modified-Since-Version", "Last-Modified", "Last-Modified-Version", "If-Unmodified-Since-Version", "Zotero-Write-Token", "If-Match", "If-None-Match", "Zotero-API-Version", "Backoff", "Retry-After", "Content-Type");
$aheaders = apache_request_headers();
$headers = array();
foreach ($aheaders as $key => $val) {
    if (in_array($key, $relevantHeaders)) {
        $headers[$key] = $val;
    }
}
$response = $library->proxyHttpRequest($requestUrl, strtoupper($requestMethod), $rawbody, $headers);
//take the http response we got and send all of it along
$httpHeaders = $response->getHeaders();
$statusSent = false;
foreach ($httpHeaders as $key => $val) {
    $headerText = $key . ': ' . $val;
    if (!$statusSent) {
        header($headerText, true, $response->getStatus());
        $statusSent = true;
    } else {
        header($headerText);
    }
}
echo $response->getBody();
/*
//getHeader function from Zend_Controller_Request_Http