Team setup called 'Emergency Management' Only members of that team can use pause button Pause button will push all scheduled messages back to at least 7 days Only memebers part of 'EM' team can send new messages, all other get queued ----------------------------------------------------------------------------- Setup Requirements: organization_id - 832420 emergency_team_id - 501006 1) Login https://apis.hootsuite.com/auth/oauth/v2/authorize https://apis.hootsuite.com/auth/oauth/v2/token Password: grant_type: password client_id client_secret username password scope 2) Check org permissions Get teams member is part of: https://apis.hootsuite.com/v1/organizations/{organizationId}/members/{memberId}/teams If part of 'EM' then grant access and create user account. Show Pause Button 3) Pause button pressed! Check if paused already/. IF NOT Get all messages: https://apis.hootsuite.com/v1/messages ?startTime=2020-01-01T00%3A00%3A00Z // Now &endTime=2020-01-15T17%3A55%3A01Z // Now +7 days &socialProfileIds=1234 // Hopefully blank, or we need to get a list &state=SCHEDULED &limit=100 // Now have all message in an array Loop through them and schedule each one + 7 days 1) DELETE MESSAGE 2) CREATE MESSAGE Set Paused to yes Org table IF ALREADY PAUSED Set Paused to no in Org table 4) Prescreening New webhook arrives for new message https://yourserver.com/webhooks/messageHandler [ { "type":"com.hootsuite.messages.event.v1", "data":{ "state":"PENDING_APPROVAL", "organization": { "id":"776781" }, "message": { "id":"4094517701" }, "timestamp":"2016-07-19T21:51:32.175Z" } } ] 1) Authenticate using client creds https://apis.hootsuite.com/auth/oauth/v2/token Content-Type: application/x-www-form-urlencoded grant_type=client_credentials& client_id={your_client_id}& client_secret={your_client_secret} --- 200 OK { "data": { "access_token": "bf63f201-a244-4298-a867-b4d343df2cf0", "token_type": "Bearer", "expires_in": 31536000, "scope": "oob" } } 2) Request org app token to get approve/reject permissions https://apis.hootsuite.com/v1/tokens Authorization: Bearer bf63f201-a244-4298-a867-b4d343df2cf0 Content-Type: application/json { "organizationId": "776781" } --- 200 OK { "data": { "access_token": "e9a90a81-xf2d-dgh3-cfsd-23jhvn76", "expires_in": 31536000 } } 3) Get all data about message https://apis.hootsuite.com/v1/messages/4094517701 Authorization: Bearer e9a90a81-xf2d-dgh3-cfsd-23jhvn76 SAVE IN DB 4) Retrieves the teams an organization member is in. https://apis.hootsuite.com/v1/organizations/{organizationId}/members/{memberId}/teams 5) If member is part of 'EM' Team Then Proceed: https://apis.hootsuite.com/v1/messages/4094517701/approve { "sequenceNumber" : 1 } Reject Message is not part of 'EM' team https://apis.hootsuite.com/v1/messages/4094517701/reject { "reason": "The message contains profanity", "sequenceNumber" : 1 } users ------ id memberid - String email - String full_name - String company_name - String timezone - String access_token - String expires_in - int prescreening : false deleted_messages php artisan make:migration create_deleted_messages_table ------- id message_id user_id status message_data - JSON dump created_messages php artisan make:migration create_created_messages_table ------- id message_id user_id status message_data - JSON dump prescreening php artisan make:migration create_prescreening_table ------------- id message_id user_id status - rejected/approved reason - String