Reputation: 11915
I have posted an example AMP page onto a heroku project;
http://boiling-garden-78683.herokuapp.com
I have then tried to use the following curl command to get the AMP cache URL:
curl -i -s -k -X POST -H "Content-Type: application/json" -H "X-Goog-Api-Key:<MYKEY>" -d "{urls: ['http://boiling-garden-78683.herokuapp.com/']}" "https://acceleratedmobilepageurl.googleapis.com/v1/ampUrls:batchGet"
This curl command is returning:
{
"urlErrors": [
{
"errorCode": "NO_AMP_URL",
"errorMessage": "No AMP URL for the request URL.",
"originalUrl": "http://boiling-garden-78683.herokuapp.com/"
}
]
}
What am I not understanding about AMP? Isn't the whole purpose of making an AMP page so that I can get an AMP URL to give to users instead of them having to go to my site directly?
Upvotes: 1
Views: 1446
Reputation: 498
You can also directly construct the AMP Cache URL. The logic is pretty simple: remove the protocol (http://
in this case), and prefix https://cdn.ampproject.org/c/
. If your page is served from https, you would use https://cdn.ampproject.org/c/s/
.
But yes, the API you are using only returns results that have already been cached. You can prime the cache with the update-ping
URL that Nick provided and then it should work.
Upvotes: 0
Reputation: 225
You have two options:
Wait when will google crawler find your pages changes
Just do this call by "curl" or just go the link using browser:
curl https://cdn.ampproject.org/update-ping/c/s/boiling-garden-78683.herokuapp.com
Then the API call you provided will return what you want ;) Mechanism of updating AMP cache (or if not in cache it will add if your AMP is valid) is described on this Update AMP Content page.
Upvotes: 3