我是 Slim Framework 3 的新手。我在访问具有 Api Key 标头值的 Web 服务时遇到问题。我有一个 Api Key 值并想访问 Web 服务以获取 JSON 数据。这是我的苗条获取方法代码:
$app->get('/getbooking/{id}', function (Request $request, Response $response, $args) {
$id = $args['id'];
$string = file_get_contents('http://maindomain.com/webapi/user/'.$id);
//Still confuse how to set header value to access the web service with Api Key in the header included.
});
我已经尝试使用 Postman(chrome 应用程序)中的 Web 服务进行访问,我得到了结果。我使用 GET 方法并为 Api Key 设置 Headers 值。
但是如何在 Slim 3 中设置 Headers 值来访问 Web 服务呢?
感谢提前:)