开发者

Facebook credit api problem

开发者 https://www.devze.com 2023-03-05 21:40 出处:网络
I am using facebook credits api and using its pay method, following is my code: <script type=\"text/javascript\">

I am using facebook credits api and using its pay method, following is my code:

 <script type="text/javascript">
 window.fbAsyncInit = function() {
    FB.init({
      'appId'   : '<?php echo $app_id; ?>',
      'session' : <?php echo json_encode($session); ?>, // don't refetch the session when PHP already has it 
      'status'  : true, // check login status
      'cookie'  : true, // enable cookies to allow the server to access the session
      'xfbml'   : true // parse XFBML
    });


    // whenever the user logs in, we refresh the page
    FB.Event.subscribe('auth.login', function() {
      window.location.reload();
    });
    FB.Canvas.setAutoResize();
 };

  (function() {
   FB_RequireFeatures(["CanvasUtil"], function() {
            FB.CanvasClient.scrollTo(0, 0);
            window.FB = null;

            var e = document.createElement('script');
            e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
            e.async = true;
            document.getElementById('fb-root').appendChild(e);
        });
  }());
</script>
    <script type="text/javascript">
        function placeOrder() {

  var order_info = { "title":"Music Mood Points",
                     "description":"Get Music Mood Points to purchase avatars",
                     "price":"10",
                     "product_url":"abc"
                   };

  // calling the API ...
  var obj = {
    method: 'pay',
    order_info: order_info,
    purchase_type: 'item'
  };

  FB.ui(obj, callback);
}

var callback = function(data) {
  if (data['order_id']) {
    writeback("Transaction Completed! </br></br>"
    + "Data returned from F开发者_StackOverflowacebook: </br>"
    + "<b>Order ID: </b>" + data['order_id'] + "</br>"
    + "<b>Status: </b>" + data['status']);
  } else if (data['error_code']) {
    writeback("Transaction Failed! </br></br>"
    + "Error message returned from Facebook:</br>"
    + data['error_message']);
  } else {
    writeback("Transaction failed!");
  }
};
  </script>
function writeback(str) {
  $('.get_points').html(str);
}
   </script>

And here is button to click:

 <input type="button" onclick="placeOrder();" value="GET More POINTS NOW" />

So when I click the button , it says in a facebook popup: Your application is not responding correctly.

So is there some thing missing in code or some thing that need to specify from application settings. Do any one have any idea. Any little thing you can tell is appreciated.

thanks in advance


When you place an order Facebook is making an backend call to your server (to the path set in the application setting page (under credit section).

That error means your application is not replying correctly to that initial call (there are actually two that will take place)

See http://developers.facebook.com/docs/creditsapi/ for more including sample code for your backend.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号