Created
January 16, 2012 18:55
-
-
Save drlongnecker/1622328 to your computer and use it in GitHub Desktop.
Posting to Campfire from PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param ( | |
[string]$RoomNumber = (Read-Host "The room to post to (default: 123456) "), | |
[string]$Message = (Read-Host "The message to send ") | |
) | |
$defaultRoom = "123456" | |
if ($RoomNumber -eq "") { | |
$RoomNumber = $defaultRoom | |
} | |
$authToken = "YOUR AUTH TOKEN" | |
$postUrl = "https://YOURDOMAIN.campfirenow.com/room/{0}/speak.json" -f $RoomNumber | |
$data = "`"{'message':{'body':'From PowerShell: - " + $message'}}`"" | |
$command = "curl -i --user {0}:X -H 'Content-Type: application/json' --data {1} {2}" -f $authToken, $data, $postUrl | |
$result = Invoke-Expression ($command) | |
if ($result[0].EndsWith("Created") -ne $true) { | |
Write-Host "Error!" -foregroundcolor red | |
$result | |
} | |
else { | |
Write-Host "Success!" -foregroundcolor green | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks!
Need support for sound messages? We've got it!
https://github.com/remotex/Scripts/blob/master/SendTo-Campfire.ps1