• First of all thanks for creating this nice plugin. We have been testing it for the last week and it works very good. There is one problem we encountered where we are not sure how to fix it (if possible)

    We use the plugin with AMP (AMP Plugin) and voting works fine on the AMP version of the website as well, but when a user comes from the google search to the AMP version cached on the Google servers, stars are shown and it allows you to vote, but after clicking on one of the stars, it returns an error message and not data is forwarded to the database. This only happens when AMP is served from Google directly (easiest way to test is with chrome on a mobile device (if served from google directly the result is a marked with an small icon in the search results)

    Thanks for your help and support!

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Support Blaz K.

    (@blazk)

    Hi @dontwakeme,

    Any chance you could send me a link so I can test? The thing is that I don’t have any AMP website and thus it’s difficult for me to debug this. By the way, what does the error say?
    Regards,
    Blaz

    Thread Starter dontwakeme

    (@dontwakeme)

    Hello @blazk,
    thanks for the fast reply.

    We currently testing in on this website:
    HTML Version:
    https://www.wettbuero-finden.com/wien/
    AMP Version:
    https://www.wettbuero-finden.com/wien/?amp

    as mentioned both work fine but not when AMP is served from google server the error occurs. Error message: “There was an error rating this post”
    To reporduce this I would suggest using chrome on a mobile device.
    Surf on your moible to:
    https://www.google.de/amp/s/www.wettbuero-finden.com/wien/%3famp

    If it this not work you can take the route through normal search on your mobile device:
    https://www.google.de/search?source=hp&ei=7gkoX9i9DpKBjLsP1eCPiAY&q=wettb%C3%BCro+wien&oq=&gs_lcp=ChFtb2JpbGUtZ3dzLXdpei1ocBABGAAyAggpMgYIKRAWEB4yAggpMgIIKTIGCCkQFhAeMgIIKTICCCkyAggpMgQIKRBDMgQIKRBDMgIIKTICCCkyAggpMgIIKTICCClQAFgAYLEMaABwAHgAgAEAiAEAkgEAmAEAsAEP&sclient=mobile-gws-wiz-hp

    this query should feature the website on one of the top poistions. If AMP is served from Google directly the search result has a small icon next to it.
    After clicking on the result you should not be taken to the domain itself but to a google server so the URL will be something like:
    https://www.google.de/amp/s/www.wettbuero-finden.com/wien/%3famp

    Thanks for your time and help!

    Plugin Support Blaz K.

    (@blazk)

    I see the problem. My guess is that the issue is caused by headers in public function process_rating_amp() on line 323 in wp-content/plugins/rate-my-post/public/class-rate-my-post-public.php. More about this here. Any chance you could test if this is the problem?

    Blaz

    Thread Starter dontwakeme

    (@dontwakeme)

    I am no dev, but I will try to test if this is the cause of the problem (seems very likely after reading into it)
    I have checked out the resource on the amp website as well: https://amp.dev/documentation/guides-and-tutorials/learn/amp-caches-and-cors/amp-cors-requests/

    so what i did now is adding the amp project URL of the website to the file:

    header("Access-Control-Allow-Origin: https://wettbuero-finden-com.cdn.ampproject.org");

    It will take some time to get it online and for google servers to update as well (if this is necessary) but if it works, it should proove where ther error comes from.

    Of course this is not a really good solution since it won’t work that easily on multipress. Well we will see I guess.

    If you have other suggestions please let me know!
    I will tell you once our test is done. Thanks for your time and help!

    Thread Starter dontwakeme

    (@dontwakeme)

    Already found my first mistake:

    header("Access-Control-Allow-Origin: https://wettbuero--finden-com.cdn.ampproject.org");

    since – gets converted into — in the AMP URL.

    Thread Starter dontwakeme

    (@dontwakeme)

    Well this did not work. Sorry!
    Do you have any code example that I should try?
    Thanks!

    Thread Starter dontwakeme

    (@dontwakeme)

    Again another update since i did not fully test it before.

    So with this solution the error message is still shown after voting on AMP, BUT the vote gets counted and the voting count goes up in the database. So it seems like vote gets through but besides this there is still an error message. Maybe allow-origin has to be added somewhere else as well? But this is just me guessing – sry!

    Plugin Support Blaz K.

    (@blazk)

    @dontwakeme, sorry for my late reply. Have you tried setting the headers like this:

    $domain_url = (isset($_SERVER[‘HTTPS’]) ? “https” : “http”) . “://$_SERVER[HTTP_HOST]”;
    header(“Content-type: application/json”);
    header(“AMP-Access-Control-Allow-Source-Origin: ” . $domain_url);
    header(“Access-Control-Expose-Headers: AMP-Access-Control-Allow-Source-Origin”);

    Does it work? If it does please let me know. I will look into this issue more thoroughly and include a patch in the next update.

    Regards,
    Blaz

    Thread Starter dontwakeme

    (@dontwakeme)

    Sorry for the late reply – I am on vacation until next week.

    The line

    header(“Access-Control-Expose-Headers: AMP-Access-Control-Allow-Source-Origin”);

    was missing in my file.
    I will add it next week and tell you how it went

    Plugin Support Blaz K.

    (@blazk)

    Perfect! Thank you!

    Thread Starter dontwakeme

    (@dontwakeme)

    unfortunately we don’t have enough time this week – sorry. We will test it next Monday. Thx for your patience!

    Thread Starter dontwakeme

    (@dontwakeme)

    Just did some tests with adding
    header(“Access-Control-Expose-Headers: AMP-Access-Control-Allow-Source-Origin”);

    always ended in an unexpected error -> site not working anymore/plugin could not be actived.

    We will end the tests for now since we got other projects to focus on. Sorry we could not help solving this issue.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Voting not working on Google AMP servers’ is closed to new replies.