Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which AMP extensions can fetch a response from an endpoint?

What AMP extensions can be used to get a response from the server in the form of variable that can be used later, such as in a template or as a parameter to an attribute?

like image 490
Dan Dascalescu Avatar asked Oct 29 '16 01:10

Dan Dascalescu


1 Answers

amp-access

The authorization endpoint of amp-access can return "a free-form JSON object":

Here’s a small list of possible ideas for properties that can be returned from the Authorization endpoint:

  • Metering info: maximum allowed number of views and current number of views.
  • Whether the Reader is logged in or a subscriber.
  • A more detailed type of the subscription: basic, premium
  • Geo: country, region, custom publication region

amp-form

amp-form "allows publishers to render the responses using Extended Templates". The response is expected to be a valid JSON Object. Try the "Hiding input fields after success" demo in the amp-form sample to see it in action.

amp-form submission with page update

amp-list

amp-list fetches "content dynamically from a CORS JSON endpoint and renders it using a supplied template". The response must be a JSON object that contains an array property "items".

In addition to {{variable}} substitutions in Mustache templates, you can also use AUTHDATA(variable) elsewhere.

amp-live-list (not quite)

amp-live-list is a "wrapper and minimal UI for content that updates live in the client instance as new content is available in the source document". The page will re-fetch itself, giving the server a change to send new content. If new content is found, AMP will populate a <div items> element with the new (HTML) items. You can't use that as a variable.

like image 126
Dan Dascalescu Avatar answered Nov 02 '22 11:11

Dan Dascalescu