shalvah / crs-request

该包已被废弃且不再维护。未建议替代包。

轻松发送HTTP请求到Hotels.ng CRS API。

2.0.0 2017-08-05 11:52 UTC

This package is auto-updated.

Last update: 2021-03-12 07:20:38 UTC


README

轻松对Hotels.ng CRS API发起请求。

如何使用

从Composer中引入包 "shalvah/crs-request":"^2.0"。这样就完成了。以下是一个示例实现。

// Configuration details
$config  = [
  'base_url' => 'http://api.hng.tech',
  'client_id' => '12345',
  'client_secret' => 'SUPER_SECRET_CLIENT_SECRET',
  'scopes' => ['locations.read', 'hotels.read'],
  'storage_path' => '/tmp' // optional
  ];
$request = new HNG\Http\Request($config);
$hotels = $request->get('/hotels');

调试

每次发生错误时,错误详情都会记录在您的storage path(如果已设置,否则为顶级目录)的log目录中。以下是记录信息的示例

[2016-12-05 03:16:52]
Endpoint: http://api.somesite.com/posts
Error:    cURL error 56: Problem (2) in the Chunked-Encoded data (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)