Last active
November 30, 2024 21:44
-
-
Save alex-grover/d8a03a34c7eb9485fe2f8e1d5fcb1013 to your computer and use it in GitHub Desktop.
Warpcast Direct Cast Script
This file contains hidden or 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
// Get a developer API key from https://warpcast.com/~/developers/api-keys | |
const API_KEY = '' | |
// Update message | |
const message = '' | |
// Update with recipient FIDs | |
const fids = [10259] | |
for (const fid of fids) { | |
const response = await fetch( | |
'https://api.warpcast.com/v2/ext-send-direct-cast', | |
{ | |
method: 'PUT', | |
headers: { | |
Authorization: `Bearer ${API_KEY}`, | |
'Content-Type': 'application/json', | |
}, | |
body: JSON.stringify({ | |
recipientFid: fid, | |
message, | |
idempotencyKey: fid, | |
}), | |
}, | |
) | |
switch (response.status) { | |
case 200: | |
console.log(`[success] fid: ${fid}`) | |
break | |
case 403: | |
console.log(`[error:permissions] fid: ${fid}`) | |
break | |
case 429: | |
console.log(`[error:rate-limit] fid: ${fid}`) | |
break | |
default: | |
console.log(`[unknown] status: ${response.status}`) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment