Using /update-cache requests to update AMP pages

守給你的承諾、 提交于 2019-12-01 08:42:05

There's an error in $signatureUrl - it should be amp_ts instead of _ts in the query params and in openssl_sign add the fourth parameter openssl_sign($signatureUrl, $signature, $pkeyid, OPENSSL_ALGO_SHA256);

The signature needs to be signed with SHA256, if you omit the last parameter it uses SHA1

I've used your script with these 2 changes for my work project and it's working fine.

It should return "OK" in the response body if it's fine.

Check this https://gist.github.com/krzysztofbukowski/739ccf4061d69360b5b2c8306f5878bd

kul3r4

Try to set the response content type to "text/plain" for https://www.qponverzum.hu/.well-known/amphtml/apikey.pub as recommended in here

=========

I use the script for update cache, but I got the 403 forbidden error. It's hard to debug and find out the root cause. Did someone succed?

All the other answers have really helped - thanks. I'm adding a little here which may hopefully also help.

As @kul3r4 points out (I missed it first time round) the apikey.pub file needs to be served as plain text. Here is the Nginx config rule for that;

    location /.well-known/amphtml/apikey.pub { ## serve amp public key as plain/text
         default_type text/plain;
    }

If you are echoing out @Krzysztof Bukowski's answer to the screen, the fact that &amp is in the url parameters means my browser was stripping out the amp part of the amp_ts and amp_url_signature so be aware of that.

If you are struggling with the file paths and syntax of this;

    $pkeyid = openssl_pkey_get_private("file://amp-private-key.pem");

Then just follow this answer here and put the contents of your private key in a variable -> Openssl and PHP

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!