nwidart/activity

Activity 允许您列出在 Github 上的当前活动。不久也将支持 Bitbucket。

dev-master 2015-04-17 15:28 UTC

This package is auto-updated.

Last update: 2020-01-07 20:22:41 UTC


README

Scrutinizer Code Quality Latest Stable Version Total Downloads Latest Unstable Version License SensioLabsInsight

Activity

Activity 允许您列出在 Github 上的当前活动。不久也将支持 Bitbucket。

重要提示

请注意,此包仍在开发中(W.I.P.),这意味着并非所有事件类型都已实现。

尚未实现的事件类型 未实现

  • ForkEvent
  • PublicEvent
  • ReleaseEvent

可用的 事件

  • CreateEvent
  • DeleteEvent
  • IssueCommentEvent
  • PullRequestEvent
  • PushEvent
  • WatchEvent
  • IssuesEvent
  • CommitCommentEvent
  • GollumEvent
  • PullRequestReviewCommentEvent

安装

在您的 composer.json 文件中添加以下内容

{
    "require": {
        "nwidart/activity": "dev-master"
    }
}

app/config/app.php 中添加服务提供者

'providers' => [
	...
    'Nwidart\Activity\ActivityServiceProvider'
]

接下来添加外观

'aliases' => [
	...
    'Activity'          => 'Nwidart\Activity\ActivityFacade',
]

最后发布配置文件

php artisan config:publish Nwidart/activity

并添加您的 Github 应用程序令牌。

使用方法

使用方法非常简单直接。

构造函数/方法注入

public function __construct(Activity $activity)
{
    $this->activity = $activity;
}

public function getIndex()
{
    $activities = $this->activity->forUser('nwidart')->activities();
}

activities 方法接受一个整数,表示活动的限制。默认为 5。

使用外观

$activities = ActivityFacade::forUser('nwidart')->activities();

响应将是

array (size=5)
  0 =>
    array (size=6)
      'time' => string '2 hours ago' (length=11)
      'actor' => string 'nWidart' (length=7)
      'actor_avatar' => string 'https://avatars.githubusercontent.com/u/882397?' (length=47)
      'verb' => string 'pushed to ' (length=10)
      'action_object' => string 'nWidart/portfolio' (length=17)
      'target' => string 'https://github.com/nWidart/portfolio/commit/5fae34f185d7b52e4de4c3597df7218af024c9e1' (length=84)
  1 =>
    array (size=6)
      'time' => string '8 hours ago' (length=11)
      'actor' => string 'nWidart' (length=7)
      'actor_avatar' => string 'https://avatars.githubusercontent.com/u/882397?' (length=47)
      'verb' => string 'pushed to ' (length=10)
      'action_object' => string 'nWidart/portfolio' (length=17)
      'target' => string 'https://github.com/nWidart/portfolio/commit/bba88e3d9bbaa1c13e98100d3da7fa3becbbd3f1' (length=84)
  2 =>
    array (size=6)
      'time' => string '8 hours ago' (length=11)
      'actor' => string 'nWidart' (length=7)
      'actor_avatar' => string 'https://avatars.githubusercontent.com/u/882397?' (length=47)
      'verb' => string 'pushed to ' (length=10)
      'action_object' => string 'nWidart/portfolio' (length=17)
      'target' => string 'https://github.com/nWidart/portfolio/commit/275c0627c449eb3370bf50e46bad8987d74e1c9a' (length=84)
  3 =>
    array (size=6)
      'time' => string '8 hours ago' (length=11)
      'actor' => string 'nWidart' (length=7)
      'actor_avatar' => string 'https://avatars.githubusercontent.com/u/882397?' (length=47)
      'verb' => string 'pushed to ' (length=10)
      'action_object' => string 'nWidart/portfolio' (length=17)
      'target' => string 'https://github.com/nWidart/portfolio/commit/beba6f74cd40eef52a46195026e80d136beb90ee' (length=84)
  4 =>
    array (size=6)
      'time' => string '13 hours ago' (length=12)
      'actor' => string 'nWidart' (length=7)
      'actor_avatar' => string 'https://avatars.githubusercontent.com/u/882397?' (length=47)
      'verb' => string 'pushed to ' (length=10)
      'action_object' => string 'nWidart/portfolio' (length=17)
      'target' => string 'https://github.com/nWidart/portfolio/commit/7c23584cd4dca9eea529a15fc61da0afe2ea0485' (length=84)

许可(MIT)

版权所有 (c) 2013 Nicolas Widart , n.widart@gmail.com

以下条件,任何人都可以免费获得此软件及其相关文档副本(“软件”),以无限制地处理软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件副本,并允许将软件提供给他人,使其可以这样做,但受以下条件约束

上述版权声明和本许可声明应包含在软件的所有副本或主要部分中。

本软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于适销性、特定用途的适用性和非侵权性。在任何情况下,作者或版权所有者不对任何索赔、损害或其他责任负责,无论这些索赔、损害或其他责任是因合同、侵权或其他方式引起的,与软件或其使用或其他方式有关。