Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Facebook信用卡的实施有什么问题_Php_Facebook_Facebook Graph Api - Fatal编程技术网

Php Facebook信用卡的实施有什么问题

Php Facebook信用卡的实施有什么问题,php,facebook,facebook-graph-api,Php,Facebook,Facebook Graph Api,我正在按照计划实施FB信用,但它不起作用 我添加了警报语句,以确保代码正在执行,从警报消息中,我确保没有js错误,并且正在调用FB.ui。我在回调函数中也有警报消息,但没有收到响应 5个小时以来,我一直在绞尽脑汁去找出代码中的错误。谁能帮帮我吗 有关应用程序的其他信息: 画布应用程序 未发布(已启用沙盒模式) 未在公司注册。FB说我可以晚些时候做,所以我刚刚设定了国家。我没有注册,因为我需要得出一个结论,我需要提供哪些银行账户的详细信息,因为FB不允许更改(从界面) 这是buy.php &

我正在按照计划实施FB信用,但它不起作用

我添加了警报语句,以确保代码正在执行,从警报消息中,我确保没有js错误,并且正在调用FB.ui。我在回调函数中也有警报消息,但没有收到响应

5个小时以来,我一直在绞尽脑汁去找出代码中的错误。谁能帮帮我吗

有关应用程序的其他信息:

  • 画布应用程序
  • 未发布(已启用沙盒模式)
  • 未在公司注册。FB说我可以晚些时候做,所以我刚刚设定了国家。我没有注册,因为我需要得出一个结论,我需要提供哪些银行账户的详细信息,因为FB不允许更改(从界面)

这是buy.php

<?php 
include_once '/Config.php';
include_once '/fb-sdk/facebook.php';
?>
<html>
    <head>
      <title>My Facebook Credits Page</title>
    </head>
    <body>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
  FB.init({
    appId  : '<?php echo Config::$appId?>',
    status : true, // check login status
    cookie : true, // enable cookies to allow the server to access the session
    xfbml  : true, // parse XFBML
    channelUrl : 'http://localhost/buy.php', // channel.html file
    oauth  : true // enable OAuth 2.0
  });

var callback = function(data) {
    if (data['order_id']) {
        alert('called back');
      return true;
    } else {
      //handle errors here
      alert('some error');
      return false;
    }
  };

function placeOrder(){

    alert('in placeOrder()');

    var order_info = 'myorderinfo';
    alert('creating obj');

    var obj = {
            method: 'pay',
            order_info: order_info,
            action: 'buy_item',
            dev_purchase_params: {'oscif': true}
          };
     alert('calling ui');
     FB.ui(obj, callback);

}

</script>

<input type="button" value="post" onclick="postFeed()" />
<input type="button" value="Buy" onclick="placeOrder()" />
</body>
 </html>
这是工作良好,并张贴在我的墙上饲料

我还使用中给出的示例实现了callback.php

是的,我已经正确配置了应用程序设置

callback.php

 <?php

include_once 'Config.php';

mysql_connect('localhost','root','');
mysql_select_db("precious_world");

//var_dump($_REQUEST);
//dump the request into the db
$request = join(':', $_REQUEST);
$request = mysql_real_escape_string($request);
$query = "insert into fbcredits_callback(data)values('$request')";
$result = mysql_query($query);

$fb_signed_req = $_REQUEST['signed_request'];

echo parse_signed_request($signed_request, Config::$appSecret);

function parse_signed_request($signed_request, $secret) {
  list($encoded_sig, $payload) = explode('.', $signed_request, 2); 

  // decode the data
  $sig = base64_url_decode($encoded_sig);
  $data = json_decode(base64_url_decode($payload), true);

  if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') {
    error_log('Unknown algorithm. Expected HMAC-SHA256');
    return null;
  }

  // check sig
  $expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true);
  if ($sig !== $expected_sig) {
    error_log('Bad Signed JSON signature!');
    return null;
  }

  return $data;
}

function base64_url_decode($input) {
  return base64_decode(strtr($input, '-_', '+/'));
}

?>

我在你的一个频道URL中看到了“localhost”,但如果你也使用localhost作为你的信用卡回调URL,Facebook将无法访问它(因此,信用卡订单无法继续进行)

aaaaaaw,因此我不得不在prod.ty中进行托管。我会检查的,所以为了检查订单的事情,我必须提到现场网址?没有其他办法吗?不,你可以使用另一个URL,但它必须能被Facebook服务器访问。
 <?php

include_once 'Config.php';

mysql_connect('localhost','root','');
mysql_select_db("precious_world");

//var_dump($_REQUEST);
//dump the request into the db
$request = join(':', $_REQUEST);
$request = mysql_real_escape_string($request);
$query = "insert into fbcredits_callback(data)values('$request')";
$result = mysql_query($query);

$fb_signed_req = $_REQUEST['signed_request'];

echo parse_signed_request($signed_request, Config::$appSecret);

function parse_signed_request($signed_request, $secret) {
  list($encoded_sig, $payload) = explode('.', $signed_request, 2); 

  // decode the data
  $sig = base64_url_decode($encoded_sig);
  $data = json_decode(base64_url_decode($payload), true);

  if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') {
    error_log('Unknown algorithm. Expected HMAC-SHA256');
    return null;
  }

  // check sig
  $expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true);
  if ($sig !== $expected_sig) {
    error_log('Bad Signed JSON signature!');
    return null;
  }

  return $data;
}

function base64_url_decode($input) {
  return base64_decode(strtr($input, '-_', '+/'));
}

?>