I am in the same boat here trying to set up an IFTTT applet to post items bookmarked a certain tag in Pinboard (I have other applets posting to Mastodon where I am able to pass a token as a header item rather than GET parameters).
My mediocre PHP chops fully see how your code works, my question being less knowledgable of the discourse server, is where can I place the script? Does it need to be on same server to avoid CORS issues?
Or should I be looking at some other integration middle platform than IFTTT?