hubersen / mitey

此包最新版本(dev-master)没有提供许可证信息。

mite API 的 PHP 封装

dev-master 2020-10-20 19:50 UTC

This package is not auto-updated.

Last update: 2024-09-24 03:02:53 UTC


README

此脚本通过 PHP 对象提供对 mite API 的便捷访问。您将能够在 IDE 中使用代码提示。

需求

Mitey 需要以下条件

  • PHP 5.3.0 或更高版本
  • PHP cURL

快速开始

将此仓库克隆到任何 web 服务器中,并调用 examples/index.php,在那里您可以输入您的 mite API 凭据并测试一些方法和检查此脚本提供的响应值。如果您由于任何原因无法克隆此代码,您可以去 http://dev.codeschmiede.de/Mitey/examples/ 查看示例页面。

使用方法

<?php
// include the Mite class
require_once 'mite/Mite.php';
// instantiate the object with your credentials
$mite = new Mite\Mite('YOUR-MITE-API-ENDPOINT', 'YOUR-MITE-API-KEY');

现在您可以访问 mite API 的所有方法,例如获取所有客户的对象

<?php
$customers = $mite->getCustomers();
for ($customers->rewind(); $customers->valid(); $customers->next())
{
	$customer = $customers->current();
	echo $customer->name . "<br />";
}

// all this methods will return iterator objects
$iterator = $mite->getArchivedProjects();
$iterator = $mite->getCustomers();
$iterator = $mite->getProjects();
$iterator = $mite->getTimes();
$iterator = $mite->getGroupedTimes(array('week, project'));
$iterator = $mite->getUsers();

获取指定账户的客户详细信息

<?php
$customer = $mite->getCustomer(1234); // 1234 is the needed customer id
// $customer contains a object of type MiteCustomer

将新内容添加到您的 mite 账户(客户、项目、时间)

<?php
// new customer
$newCustomer = $mite->addCustomer(array(
	'name' => 'My new customer name',
	'note' => 'Generated via Mitey, totally easy. Whoop whoop.'
));

// new project
$newProject = $mite->addProject(array(
	'name' => 'My brand new project',
	'note' => 'Generated via Mitey, totally easy. Whoop whoop.',
	'customer_id' => $newCustomer->id
));

// new time entry
$newtime = $mite->addTime(
	date('Y-m-d'), 			// date of time entry
	666, 					// time in seconds
	'My workdescription, created via Mitey, whoop whoop.',
	$mite->getMyself()->id,	// user id
	$newProject->id,		// optional: project id
	false					// optional: service id
);

查看代码 Mite/Mite.php 以获取此库提供的完整方法列表。

联系

如果您想取得联系,这很容易!