facebook og data not updating

2019-09-01 05:46发布

I have created a facebook app with subscription.

When the user opens the app, there is a button called "SUBSCRIBE". When it is clicked, the javascript function completePayment(), is called. The facebook popup with subscribe appears. However, there is a big problem. If I change the og:image URL and set the price to let's say 10.00 USD and the billing period to 1 month and I upload the file to the server and then I click on the SUBSCRIBE button, I can still see the subscription page saying 5.00 USD/week and the image is blank.

It's like everything remained the same way that it was when I first set the data, even though I updated all the data from https://www.mydomain.com/_product.php , with the new values. I even logged out and relogged in, and still no changes are reflected.

I even emptied the _product.php page and uploaded it to the server and the subscription still works and shows 5.00 USD/week and the image is blank.

Any ideas on how to fix this?

I have this code on the main page:

<a href="#" onclick="completePayment()"> 
    <img src="https://www.**********.com/subscribe.png" alt="Subscribe" title="Subscribe" style="vertical-align: top"/>
    <script src="https://connect.facebook.net/en_US/all.js"></script>
    <script type="text/javascript">
     FB.init({
      appId:'2***********6',
      cookie:true,
      status:true,
      xfbml:true
     });
      function completePayment(){
         var obj = {
        method: 'pay',
        action: 'create_subscription',
        product: 'https://www.mydomain.com/_product.php'
     };
    FB.ui(obj);
    }
    </script>
    </a>

This is the HTML code from the 'https://www.mydomain.com/_product.php' page:

<html>
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# fbpayment: http://ogp.me/ns/fb/fbpayment#">        
    <meta property="og:title" content="********* Subscription" />
    <meta property="og:image" content="https://s-static.ak.fbcdn.net/images/devsite/attachment_blank.png" />
    <meta property="og:description" content="****** Subscription" />
    <meta property="fbpayment:price" content="5.00 USD" />
    <meta property="fbpayment:alternate_price" content="3.49 EUR" />
    <meta property="fbpayment:alternate_price" content="3.49 GBP" />
    <meta property="fbpayment:trial_duration" content="7 days" />
    <meta property="fbpayment:billing_period" content="1 week" />
    <meta property="fb:app_id" content="2*************6" />
    <meta property="og:url" content="https://www.mydomain.com/_product.php" />
    <meta property="og:type" content="fbpayment:subscription" />
</html>

1条回答
Rolldiameter
2楼-- · 2019-09-01 06:09

The facebook page have a looong if not semi permanent cache about share content: 3 options are possible:

1) try to clear the page cache on: https://developers.facebook.com/tools/debug but you will fall in the same problem next time you share the page

2) add a dynamic parameter to your url (https://www.mydomain.com/_product.php?q=123), than you will have a unique value associated with this url, but you need to set the og for this specific url with a php_get on the parameter. If you have few value you can make it manually, on the other hands if you have more value or dynamic value you need a DB table to store the data with the link url and the associated og and get the value in the php_get

3) Clear the cache programatically by re-scraping it. See: https://developers.facebook.com/docs/payments/product?locale=en_GB#scraping-object

I've done somthing similar on my site but only with random generated value: http://www.paris-web.it/test.html

查看更多
登录 后发表回答