douhan9619 2013-06-10 12:07
浏览 90

Facebook本地货币支付示例

As Facebook are forcing us to change ways once again, we need to introduce their "local currency" as payment option in our app.

However, I'm finding the documentation hard to understand, and are in desperate need of some example code. If anyone knows of some sample code, it would be greatly appreciated.

  • 写回答

2条回答 默认 最新

  • douhuan1908 2013-06-13 08:12
    关注

    I think this error occurs if you are the developer/owner of the app, try a different account

    I have only just worked this out myself and have not yet completed the callback, I will edit my answer then. Hope this is useful to someone. First make a graph object

    <head prefix=
    "og: http://ogp.me/ns# 
    fb: http://ogp.me/ns/fb# 
    product: http://ogp.me/ns/product#">
    <meta property="og:type"                   content="og:product" />
    <meta property="og:title"                  content="Friend Smash Coin" />
    <meta property="og:plural_title"           content="Friend Smash Coins" />
    <meta property="og:image"                  content="http://www.friendsmash.com/images/coin_600.png" />
    <meta property="og:description"            content="Friend Smash Coins to purchase upgrades and items!" />
    <meta property="og:url"                    content="https://www.yourdomain.com/test.html" />
    <meta property="product:price:amount"      content="0.30"/>
    <meta property="product:price:currency"    content="USD"/>
    <meta property="product:price:amount"      content="0.20"/>
    <meta property="product:price:currency"    content="GBP"/>
    </head>
    

    Save this as an html file and upload it to your server, lets say yourdomain.com/test.html

    Visit this page https://developers.facebook.com/tools/debug and enter yournew url here (yourdomain.com/test.html)

    change the product url below to your domain (yourdomain.com/test.html)

    <h2>Purchase a product:</h2>
    <button id="pay">Buy Product</button>
    <div class="returndata" id="output"></div>
    
    
    <div id="fb-root"></div>
    <script type="text/javascript">
      window.fbAsyncInit = function() {
        FB.init({
          appId      : 'APPID',
          status     : true,
          cookie     : true,
          xfbml      : true
        });
    
        function buy() {
          var obj = {
            method: 'pay',
            action: 'purchaseitem',
            product: 'http://yourdomain.com/test.html'
          };
    
          FB.ui(obj, function(data) {
              console.log(data);
            });
        }
    
        document.getElementById('pay').onclick = function() {buy()};
      };
    
      // Load the SDK Asynchronously
      (function(d){
        var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
        if (d.getElementById(id)) { return; }
        js = d.createElement('script'); js.id = id; js.async = true;
        js.src = "//connect.facebook.net/en_US/all.js";
        ref.parentNode.insertBefore(js, ref);
      }(document));
    </script>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?