Facebook signed request problem

后端 未结 1 1351
说谎
说谎 2020-12-10 21:49

I want to write a fangate for my facebook page, but it didnt work and i doesnt find any help on the inter net

require \'facebook.php\';

$app_id = \'16850872         


        
相关标签:
1条回答
  • 2020-12-10 22:14

    There are a few errors with the code you sent. This is what I use, and it works:

    if (isset($_REQUEST['signed_request'])) {
          $encoded_sig = null;
          $payload = null;
          list($encoded_sig, $payload) = explode('.', $_REQUEST['signed_request'], 2);
          $sig = base64_decode(strtr($encoded_sig, '-_', '+/'));
          $data = json_decode(base64_decode(strtr($payload, '-_', '+/'), true));
          if($data->page->liked) {
              echo "This content is for Fans only!";
            } else {
              echo "Please click on the Like button to view this tab!";
            }
        }
    

    And don't post your application secret key on the forum, please edit your post as soon as possible.

    0 讨论(0)
提交回复
热议问题