Get post from attachment (php)

I have a file attachment url, I want to get the post url.

If I click the file attachment, I get a json response that says I’m not authorized to download that.

imo, it should take the user to the post, thereby asking for their log in, taking them to the pledge screen, etc; instead, it effectively gives a wsod.

Is there a way to get the relative post from the file id returned by that json?

I’m not a Patreon developer so this might not be a solution that’ll work long term, but currently you can access a Patreon post using just the ID, and the post ID that the attachment belongs to is included in the attachment URL, so you can construct a URL to a post from an attachment using the post ID from attachment URL.

For example, if the attachment URL is this:

Then you extract the h parameter (1234) and create the following URL:

The post ID isn’t included in the JSON error response though.


:roll_eyes: I can’t believe that escaped me.

Thank you so much :smiley: