Skip to content

Instantly share code, notes, and snippets.

@dfinke
Created May 10, 2014 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dfinke/328a511d03f41bcb88b3 to your computer and use it in GitHub Desktop.
Save dfinke/328a511d03f41bcb88b3 to your computer and use it in GitHub Desktop.
Use PowerShell to list GitHub events that a user has received
function Get-GithubEvent {
param($userId,$Password)
function Get-GitHubAuthHeaders {
param($userId,$Password)
$authInfo = "$($userId):$($Password)"
$authInfo = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($authInfo))
@{
"Authorization" = "Basic " + $authInfo
"Content-Type" = "application/json"
}
}
$Headers = Get-GitHubAuthHeaders $userId $Password
$Uri = "https://api.github.com/users/$userId/received_events"
ForEach($item in (Invoke-RestMethod -Headers $Headers -Uri $Uri )) {
[PSCustomObject]@{
Action = $item.payload.action
Type = $item.type
Who = $item.actor.login
Details = $item
}
}
}
@dfinke
Copy link
Author

dfinke commented May 10, 2014

Action  Type              Who          Details                                                                                                      
------  ----              ---          -------                                                                                                      
create  GistEvent         mbostock     @{id=2092560665; type=GistEvent; actor=; repo=; payload=; public=True; created_at=2014-05-09T20:36:33Z}      
create  GistEvent         mbostock     @{id=2092475011; type=GistEvent; actor=; repo=; payload=; public=True; created_at=2014-05-09T19:37:50Z}      
create  GistEvent         mbostock     @{id=2092454060; type=GistEvent; actor=; repo=; payload=; public=True; created_at=2014-05-09T19:23:30Z}      
opened  IssuesEvent       Jaykul       @{id=2092440016; type=IssuesEvent; actor=; repo=; payload=; public=True; created_at=2014-05-09T19:14:00Z; ...
opened  IssuesEvent       Jaykul       @{id=2092430200; type=IssuesEvent; actor=; repo=; payload=; public=True; created_at=2014-05-09T19:07:22Z; ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment