_archive/testSlack.ps1



#xapp-1-A05PKCJ90RZ-5794893859766-6c5323228c29b0f80a6d5e379249811eaa461010813db4eaaf7f80515d63d61b

# good hints: https://api.slack.com/tutorials/tracks/getting-a-token?app_id_from_manifest=A05PKCJ90RZ


# App Credentials
$appId = "A05PKCJ90RZ"
$clientID = "3542927802.5801426306883"
$clientSecret = "5a27e61e1382c92803160b8820bc1f47"
$signingSecret = "cf6ba3f289ea960a2e12e2210a682044"

$token = "xoxb-3542927802-5798619124437-pGunrKED1p37ZHbPPblAjcqU"

$header = [Hashtable]@{
    "Authorization" = "Bearer $( $token )"
}

$conversations = Invoke-RestMethod -Uri "https://slack.com/api/conversations.list?pretty=1" -Method Get -Headers $header
$conversations.channels | Out-GridView -PassThru


# scope: chat:write
$body = [PSCustomObject]@{
    "channel" = "CQU215HPH"
    "text" = "I hope the tour went well, Mr. Wonka."
}
$bodyJson = ConvertTo-Json $body -Depth 99
$postMessage = Invoke-RestMethod -Uri "https://slack.com/api/chat.postMessage" -Method Post -Headers $header -ContentType "application/json" -Body $bodyJson