woeler / komoot-php

一个用于与Komoot交互的PHP库

1.1.0 2024-05-06 16:14 UTC

This package is auto-updated.

Last update: 2024-09-27 15:55:14 UTC


README

注意:Komoot已决定在登录过程中添加一个不可见的验证码。这使得这个库无法使用。我已经给他们发了一封邮件,询问是否可以找到另一种登录方式,但我还没有收到回复。

这是一个可以用于与Komoot交互的PHP库。它使用Komoot网站使用的相同API。Komoot并未正式支持将其集成到第三方项目中。我只是需要一个与Komoot交互的复杂方式来处理一个个人项目。这就是我创建这个包的原因。

使用方法

身份验证

您需要使用您的Komoot账户电子邮件地址和密码进行登录。

use Woeler\KomootPhp\Api\Komoot;

// Create the api object
$api = new Komoot('my-komoot-account@example.com', 'my-komoot-password');

// Execute the login
$api->login();

// ... You can now start making api calls

API调用

我认为重要的端点都有专门的方法。登录后,您可以简单使用它们。

// Get a single tour
$api->getTour(123);

// Get a single tour as GPX data
$api->getTourGpx(123);

// Get all tours of your account
$api->getAllTours();

// Get a single user
$api->getUser(123);

// Get a single collection
$api->getCollection(123);

您可以在Komoot类中查看,还有其他许多端点也是可用的。

如果您想调用的端点没有专门的方法,您可以使用customRequest方法。

$api->customRequest('https://api.komoot.de/v007/some-other-endpoint', [], 'GET');