定制 borivojevic/rescuetime 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

borivojevic/rescuetime

最新稳定版本:2.2.0

Composer 安装命令:

composer require borivojevic/rescuetime

包简介

PHP wrapper library for RescueTime API

README 文档

README

Build Status Scrutinizer Quality Score Code Coverage Latest Stable Version

rescuetime-api-php

PHP wrapper library for RescueTime API

At this point RescueTime API provides single endpoint to fetch detailed and complicated data. The data is read-only through the API.

Initial release of RescueTime API is targeted at bringing developers the prepared and pre-organized data structures already familiar through the reporting views of www.rescuetime.com. Keep in mind this is a draft interface, and may change in the future. RescueTime do intend to version the interfaces though, so it is likely forward compatible.

Installation

Recommend way to install this package with Composer. Add borivojevic/rescuetime-api-php to your composer.json file.

{
    "require": {
        "borivojevic/rescuetime": "2.*"
    }
}

To install composer run:

curl -s http://getcomposer.org/installer | php

To install composer dependences run:

php composer.phar install

You can autoload all dependencies by adding this to your code:

require 'vendor/autoload.php';

Usage

The main entry point of the library is the RescueTime\Client class. API methods require to be signed with valid api_key parameter which you have to provide as a first argument of the constructor. You can obtain RescueTime API key on API Key Management console page.

<?php

use RescueTime\RequestQueryParameters as Params;
use RescueTime\Client;

$client = new Client($apiKey);

// Basic example
$activities = $client->getActivities(new Params(['perspective' => 'rank']));

foreach ($activities as $activity) {
    echo $activity->getActivityName();
    echo $activity->getProductivity();
}

// Fetch activities for past week
$activities = $client->getActivities(
    new Params([
        'perspective' => 'interval',
        'resolution_time' => 'day',
        'restrict_begin' => new \DateTime("-6 day"),
        'restrict_end' => new \DateTime("today")
    ])
);

// Fetch productivity data grouped by activity
$activities = $client->getActivities(
    new Params([
        'perspective' => 'interval',
        'resolution_time' => 'day',
        'restrict_begin' => new \DateTime("-6 day"),
        'restrict_end' => new \DateTime("today"),
        'restrict_kind' => 'activity'
    ])
);

// Fetch productivity data grouped by category
$activities = $client->getActivities(
    new Params([
        'perspective' => 'interval',
        'resolution_time' => 'day',
        'restrict_begin' => new \DateTime("-6 day"),
        'restrict_end' => new \DateTime("today"),
        'restrict_kind' => 'category'
    ])
);

// Fetch daily productivity report data for past two weeks
$daily_summary = $client->getDailySummary();

foreach ($daily_summary as $day_summary) {
    echo $day_summary->getTotalDurationFormatted();
    echo $day_summary->getVeryDistractingHours();
    echo $day_summary->getVeryDistractingDurationFormatted();
}

You can build more complex queries and filter down the data by providing other query parameters:

$client->getActivities(
    new Params([
        "perspective" => <rank|interval|member>,
        "resolution_time" => <month|week|day|hour>,
        "restrict_group" => <group name>,
        "restrict_user" => <user name/user email>,
        "restrict_begin" => <\DateTime>,
        "restrict_end" => <\DateTime>,
        "restrict_kind" => <category|activity|productivity|document>,
        "restrict_project" => <project name>,
        "restrict_thing" => <category name/activity name/overview name>,
        "restrict_thingy" => <document name/activity name>
    ])
);

Each query parameter is explained in more details in official HTTP Query Interface documentation.

For a working example of an app build on top of rescuetime-api-php library take a look at borivojevic/rescuetime-statusboard.

Contributing

Patches and pull requests are welcome. Take a look at Contributing guidelines for further info.

Versioning

The library uses Semantic Versioning

Copyright and License

The library is licensed under the MIT license.

统计信息

  • 总下载量: 284
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 13
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 13
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-08-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固