php-extended/php-api-fr-gouv-datatourisme-diffuseur-object

实现了php-extended/php-api-fr-gouv-datatourisme-diffuseur-interface库的库


README

实现了php-extended/php-api-fr-gouv-datatourisme-diffuseur-interface库的库。

coverage build status

安装

此库的安装是通过composer完成的,所有类的自动加载都是通过它们的自动加载器完成的。

  • 他们的网站下载composer.phar
  • 然后运行以下命令以将此库作为依赖项安装
  • php composer.phar require php-extended/php-api-fr-gouv-datatourisme-diffuseur-object ^7

基本用法

此库可以按以下方式使用


use PhpExtended\DatatourismeDiffuseurApi\DtDiffApiEndpoint;
use PhpExtended\Endpoint\HttpEndpoint;

/** @var $client \Psr\Http\Client\ClientInterface */
// note, the client or the endpoint must do gzip
// uncompressing when retrieving the file. You may use the
// \PhpExtended\Endpoint\GzipHttpEndpoint as wrapper around
// the HttpEndpoint to do the job if the client does not.

// note2 : the client must support the X-Php-Download-File
// custm header to specify a temporary location, or do gzip
// uncompressing on the fly (as the following unzipping is
// done by this endpoint on the temp folder and the php-zip
// library needs a file to operate).

$endpoint = new DtDiffApiEndpoint('/tmp/', new GzipHttpEndpoint(new HttpEndpoint($client)));

$iterator = $endpoint->downloadFlux($fluxKey, $apiKey);

foreach($iterator as $line)
{
	try
	{
		$poi = $iterator->getPointOfInterestData($resume);
		// do something with poi object
	}
	catch(\Throwable $exc)
	{
		// do something in case object cannot be read
	}
}

许可证

MIT (见许可证文件)。