AMP-HTML mail - how to communicate with the server and fetch json?How to create a responsive hamburger menu in AMP HTMLWhat's the deal with `html ⚡` in AMP pages?amp-html page linked from non-amp html page not workingHow to fully overwrite an amp-state in AMP-HTML?How to Include a HTML File in AMPHow to fetch query string in AMP?amp html button not clickable inside amp-listDisplay Raw HTML from json to AMP pageAMP subset of HTML, or extended subset? amp-img in HTMLHow to add Roboto font to AMP 4 Email
Are differences between uniformly distributed numbers uniformly distributed?
Graphs for which a calculus student can reasonably compute the arclength
What should I call bands of armed men in the Middle Ages?
Do beef farmed pastures net remove carbon emissions?
80's/90's superhero cartoon with a man on fire and a man who made ice runways like Frozone
Programming of ICs in general (MCU / FPGA / Serdes IC)
Can I enter the USA with an E-2 visa and a one way flight ticket?
Are there really no countries that protect Freedom of Speech as the United States does?
Is it possible to grow new organs through exposure to radioactivity?
crippling fear of hellfire &, damnation, please help?
Simplification of numbers
Why aren't rockets built with truss structures inside their fuel & oxidizer tanks to increase structural strength?
Why aren’t there water shutoff valves for each room?
Does fossil fuels use since 1990 account for half of all the fossil fuels used in history?
Is there a command to install basic applications on Ubuntu 16.04?
If "more guns less crime", how do gun advocates explain that the EU has less crime than the US?
The cat ate your input again!
How to take the beginning and end parts of a list with simpler syntax?
Are those flyers about apartment purchase a scam?
Help, I cannot decide when to start the story
How can God warn people of the upcoming rapture without disrupting society?
Is it okay for a ticket seller to grab a tip in the USA?
Word for an event that will likely never happen again
Generate Brainfuck for the numbers 1–255
AMP-HTML mail - how to communicate with the server and fetch json?
How to create a responsive hamburger menu in AMP HTMLWhat's the deal with `html ⚡` in AMP pages?amp-html page linked from non-amp html page not workingHow to fully overwrite an amp-state in AMP-HTML?How to Include a HTML File in AMPHow to fetch query string in AMP?amp html button not clickable inside amp-listDisplay Raw HTML from json to AMP pageAMP subset of HTML, or extended subset? amp-img in HTMLHow to add Roboto font to AMP 4 Email
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Is it possible using AMP-HTML mail format to communicate with the server? I don't think it's documented that well. There is some info about normal AMP-HTML but not much about email.
This is amp mail I want to send. I would like secret word to be fetched from my server and not hardcoded.
<!doctype html>
<html ⚡4email>
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
<style amp4email-boilerplate>bodyvisibility:hidden</style>
</head>
<body>
<!-- Store complex nested JSON data in <amp-state> elements. -->
<amp-state id="words">
<script type="application/json">
"SecretWord": "fetched"
</script>
</amp-state>
<p [text]="'Your word is: ' + currentWord + '.'">Click to show magic word</p>
<button on="tap:AMP.setState(currentWord: words['SecretWord'])">Show word</button>
</body>
</html>
amp-html amp-email
add a comment |
Is it possible using AMP-HTML mail format to communicate with the server? I don't think it's documented that well. There is some info about normal AMP-HTML but not much about email.
This is amp mail I want to send. I would like secret word to be fetched from my server and not hardcoded.
<!doctype html>
<html ⚡4email>
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
<style amp4email-boilerplate>bodyvisibility:hidden</style>
</head>
<body>
<!-- Store complex nested JSON data in <amp-state> elements. -->
<amp-state id="words">
<script type="application/json">
"SecretWord": "fetched"
</script>
</amp-state>
<p [text]="'Your word is: ' + currentWord + '.'">Click to show magic word</p>
<button on="tap:AMP.setState(currentWord: words['SecretWord'])">Show word</button>
</body>
</html>
amp-html amp-email
add a comment |
Is it possible using AMP-HTML mail format to communicate with the server? I don't think it's documented that well. There is some info about normal AMP-HTML but not much about email.
This is amp mail I want to send. I would like secret word to be fetched from my server and not hardcoded.
<!doctype html>
<html ⚡4email>
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
<style amp4email-boilerplate>bodyvisibility:hidden</style>
</head>
<body>
<!-- Store complex nested JSON data in <amp-state> elements. -->
<amp-state id="words">
<script type="application/json">
"SecretWord": "fetched"
</script>
</amp-state>
<p [text]="'Your word is: ' + currentWord + '.'">Click to show magic word</p>
<button on="tap:AMP.setState(currentWord: words['SecretWord'])">Show word</button>
</body>
</html>
amp-html amp-email
Is it possible using AMP-HTML mail format to communicate with the server? I don't think it's documented that well. There is some info about normal AMP-HTML but not much about email.
This is amp mail I want to send. I would like secret word to be fetched from my server and not hardcoded.
<!doctype html>
<html ⚡4email>
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
<style amp4email-boilerplate>bodyvisibility:hidden</style>
</head>
<body>
<!-- Store complex nested JSON data in <amp-state> elements. -->
<amp-state id="words">
<script type="application/json">
"SecretWord": "fetched"
</script>
</amp-state>
<p [text]="'Your word is: ' + currentWord + '.'">Click to show magic word</p>
<button on="tap:AMP.setState(currentWord: words['SecretWord'])">Show word</button>
</body>
</html>
amp-html amp-email
amp-html amp-email
edited May 15 at 14:51
fstanis
3,9141 gold badge12 silver badges32 bronze badges
3,9141 gold badge12 silver badges32 bronze badges
asked Mar 27 at 10:14
qnsiqnsi
1353 silver badges13 bronze badges
1353 silver badges13 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Yes, there is no much documentation about AMP4Email. Recently, with a lot of unsuccessful efforts, I've managed to complete one of my use-case using AMP4Email.
You can refer to the below example for achieving your goal:
<!doctype html>
<html ⚡4email>
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
<style amp4email-boilerplate>bodyvisibility:hidden</style>
</head>
<body>
<amp-state id="fruits"
src="https://amp.dev/static/samples/json/related_products.json"></amp-state>
<p [text]="'My favorite fruit is : ' + favoriteFruit + '.'">Click to find my favorite fruit.</p>
<button on="tap:AMP.setState(favoriteFruit: fruits.items[0]['name'])">Show</button>
</body>
</html>
I have used an API from an example by ampproject.org, which returns a JSON of items of fruits. But, you can write your own API that sends your favorite word only.
In order to write your own service, you have to be very careful with the response headers. If you look for the response headers of this API, you'll see some headers like access-... and amp-.... These headers are mandatory if you want to use your API/ service in AMP4Email.
The mandatory Response Headers are:
AMP-Access-Control-Allow-Source-Origin: <value received in __amp_source_origin query param for your service>
Access-Control-Expose-Headers: AMP-Access-Control-Allow-Source-Origin
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token
Access-Control-Allow-Origin: <origin, e.g. 'https://mail.google.com', if your service is hit from GMail inbox)
PS: __amp_source_origin header is appended by GMail. You will receive this header for all the requests coming from AMP4Email HTML.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55374715%2famp-html-mail-how-to-communicate-with-the-server-and-fetch-json%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Yes, there is no much documentation about AMP4Email. Recently, with a lot of unsuccessful efforts, I've managed to complete one of my use-case using AMP4Email.
You can refer to the below example for achieving your goal:
<!doctype html>
<html ⚡4email>
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
<style amp4email-boilerplate>bodyvisibility:hidden</style>
</head>
<body>
<amp-state id="fruits"
src="https://amp.dev/static/samples/json/related_products.json"></amp-state>
<p [text]="'My favorite fruit is : ' + favoriteFruit + '.'">Click to find my favorite fruit.</p>
<button on="tap:AMP.setState(favoriteFruit: fruits.items[0]['name'])">Show</button>
</body>
</html>
I have used an API from an example by ampproject.org, which returns a JSON of items of fruits. But, you can write your own API that sends your favorite word only.
In order to write your own service, you have to be very careful with the response headers. If you look for the response headers of this API, you'll see some headers like access-... and amp-.... These headers are mandatory if you want to use your API/ service in AMP4Email.
The mandatory Response Headers are:
AMP-Access-Control-Allow-Source-Origin: <value received in __amp_source_origin query param for your service>
Access-Control-Expose-Headers: AMP-Access-Control-Allow-Source-Origin
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token
Access-Control-Allow-Origin: <origin, e.g. 'https://mail.google.com', if your service is hit from GMail inbox)
PS: __amp_source_origin header is appended by GMail. You will receive this header for all the requests coming from AMP4Email HTML.
add a comment |
Yes, there is no much documentation about AMP4Email. Recently, with a lot of unsuccessful efforts, I've managed to complete one of my use-case using AMP4Email.
You can refer to the below example for achieving your goal:
<!doctype html>
<html ⚡4email>
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
<style amp4email-boilerplate>bodyvisibility:hidden</style>
</head>
<body>
<amp-state id="fruits"
src="https://amp.dev/static/samples/json/related_products.json"></amp-state>
<p [text]="'My favorite fruit is : ' + favoriteFruit + '.'">Click to find my favorite fruit.</p>
<button on="tap:AMP.setState(favoriteFruit: fruits.items[0]['name'])">Show</button>
</body>
</html>
I have used an API from an example by ampproject.org, which returns a JSON of items of fruits. But, you can write your own API that sends your favorite word only.
In order to write your own service, you have to be very careful with the response headers. If you look for the response headers of this API, you'll see some headers like access-... and amp-.... These headers are mandatory if you want to use your API/ service in AMP4Email.
The mandatory Response Headers are:
AMP-Access-Control-Allow-Source-Origin: <value received in __amp_source_origin query param for your service>
Access-Control-Expose-Headers: AMP-Access-Control-Allow-Source-Origin
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token
Access-Control-Allow-Origin: <origin, e.g. 'https://mail.google.com', if your service is hit from GMail inbox)
PS: __amp_source_origin header is appended by GMail. You will receive this header for all the requests coming from AMP4Email HTML.
add a comment |
Yes, there is no much documentation about AMP4Email. Recently, with a lot of unsuccessful efforts, I've managed to complete one of my use-case using AMP4Email.
You can refer to the below example for achieving your goal:
<!doctype html>
<html ⚡4email>
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
<style amp4email-boilerplate>bodyvisibility:hidden</style>
</head>
<body>
<amp-state id="fruits"
src="https://amp.dev/static/samples/json/related_products.json"></amp-state>
<p [text]="'My favorite fruit is : ' + favoriteFruit + '.'">Click to find my favorite fruit.</p>
<button on="tap:AMP.setState(favoriteFruit: fruits.items[0]['name'])">Show</button>
</body>
</html>
I have used an API from an example by ampproject.org, which returns a JSON of items of fruits. But, you can write your own API that sends your favorite word only.
In order to write your own service, you have to be very careful with the response headers. If you look for the response headers of this API, you'll see some headers like access-... and amp-.... These headers are mandatory if you want to use your API/ service in AMP4Email.
The mandatory Response Headers are:
AMP-Access-Control-Allow-Source-Origin: <value received in __amp_source_origin query param for your service>
Access-Control-Expose-Headers: AMP-Access-Control-Allow-Source-Origin
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token
Access-Control-Allow-Origin: <origin, e.g. 'https://mail.google.com', if your service is hit from GMail inbox)
PS: __amp_source_origin header is appended by GMail. You will receive this header for all the requests coming from AMP4Email HTML.
Yes, there is no much documentation about AMP4Email. Recently, with a lot of unsuccessful efforts, I've managed to complete one of my use-case using AMP4Email.
You can refer to the below example for achieving your goal:
<!doctype html>
<html ⚡4email>
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
<style amp4email-boilerplate>bodyvisibility:hidden</style>
</head>
<body>
<amp-state id="fruits"
src="https://amp.dev/static/samples/json/related_products.json"></amp-state>
<p [text]="'My favorite fruit is : ' + favoriteFruit + '.'">Click to find my favorite fruit.</p>
<button on="tap:AMP.setState(favoriteFruit: fruits.items[0]['name'])">Show</button>
</body>
</html>
I have used an API from an example by ampproject.org, which returns a JSON of items of fruits. But, you can write your own API that sends your favorite word only.
In order to write your own service, you have to be very careful with the response headers. If you look for the response headers of this API, you'll see some headers like access-... and amp-.... These headers are mandatory if you want to use your API/ service in AMP4Email.
The mandatory Response Headers are:
AMP-Access-Control-Allow-Source-Origin: <value received in __amp_source_origin query param for your service>
Access-Control-Expose-Headers: AMP-Access-Control-Allow-Source-Origin
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token
Access-Control-Allow-Origin: <origin, e.g. 'https://mail.google.com', if your service is hit from GMail inbox)
PS: __amp_source_origin header is appended by GMail. You will receive this header for all the requests coming from AMP4Email HTML.
edited Apr 10 at 22:57
answered Apr 10 at 22:52
thisisbobbsthisisbobbs
7223 silver badges9 bronze badges
7223 silver badges9 bronze badges
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55374715%2famp-html-mail-how-to-communicate-with-the-server-and-fetch-json%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown