Skip to content

Instantly share code, notes, and snippets.

@jcallaghan
Created October 2, 2019 11:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jcallaghan/c2ded22feaa639f60fc08ea43ec3a883 to your computer and use it in GitHub Desktop.
Save jcallaghan/c2ded22feaa639f60fc08ea43ec3a883 to your computer and use it in GitHub Desktop.
function Get-BaererToken() {
$headers = @{ Authorization=("Bearer " + $token) }
return $headers
}
# Yammer app developer token
$token = "12345678-ABCDEabcdeABCDEabcdeAB"
# Base Yammer API url
$yammerBaseUrl = "https://www.yammer.com/api/v1"
# Create the json for a new message.
$messageBody = @{
body = "Video provides a powerful way to help you prove your point. When you click Online Video, you can paste in the embed code for the video you want to add. You can also type a keyword to search online for the video that best fits your document. To make your document look professionally produced, Word provides header, footer, cover page, and text box designs that complement each other"; `
group_id = "1234567890"; `
is_rich_text = $false; `
message_type = "normal";
}
# Post new message to the messages API
$headers = Get-BaererToken
$messagesApi = "$($yammerBaseUrl)/messages"
$apiResponse = Invoke-RestMethod -Uri $messagesApi -Method Post -Headers $headers -ContentType "application/json" -Body (ConvertTo-Json $messageBody)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment