Skip to content

Instantly share code, notes, and snippets.

@ericdke
Created July 30, 2017 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericdke/bce57bf1cded6887db3926a866b0fc9e to your computer and use it in GitHub Desktop.
Save ericdke/bce57bf1cded6887db3926a866b0fc9e to your computer and use it in GitHub Desktop.
Flow to get an image from a pnut.io post oembed
if the post oembed does NOT have a "url_expires_at" field:
it's not a pnut file, it's safe to use the "url" field from the post oembed
else:
if "url_expires_at" is NOT past:
it's safe to use "url" field from the post oembed
else:
if there's a "url_immediate" field:
use "url_immediate" instead of "url"
else:
use "file_id" and "file_token_read" from the post oembed to
GET /files/{file_id}?file_token_read={file_token_read}
this gives a new object if the file hasn't been deleted
and from this new object:
use the "link" field instead of "url"
use the "link_expires_at" field instead of "url_expires_at"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment