簡體   English   中英

鏈接到facebook TAB內的特定頁面

[英]Link to a specific page inside facebook TAB

您好,您好,請您為我解釋一種創建鏈接到Facebook選項卡中特定頁面的URL的方法嗎?

我有index.php page1.php page2.php這個標簽

我想創建一個可以與我的用戶共享的鏈接,這些鏈接將他們直接帶到page2.php。

我看到我必須在app_data上傳遞一個字符串,但是我如何找回它呢? 因為我的想法是這樣的: http : //facebook.com/app_id&app_data=gotosomewhere

if(gotosomewhere)
  header location

但我不知道如何獲取app_data。

謝謝。

您要查找的參數將放置在signed_request ,該參數在首次加載時傳遞給您的應用程序。

文檔有一個頁面,該頁面討論在檢查signed_request時可以看到哪些字段。

app_data-一個JSON字符串,其中包含app_data查詢字符串參數的內容,如果該應用程序正在頁面選項卡中加載,則可以通過該字符串。

如果有人需要,這就是解決此問題的方法。

facebook_data.php:

    <?php
    define('APP_ID',      'hereyourappid');
    define('APP_API_KEY', 'hereyourappid');
    define('APP_SECRET',  'hereyoursecretappid');
    error_reporting(0) ; 


    $signed_request = parse_signed_request(@$_REQUEST['signed_request'], APP_SECRET);
    defin

e('LIKED', @$signed_request['page']['liked']);

$app_data = $signed_request['page']['liked'];
$redirect = $signed_request['app_data']; /* HERE I DECLARE A VARIABLE 
THAT GET THE PARAMETER I PASS VIA URL */
$fanGate=LIKED;

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

  // 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, '-_', '+/'));
}

?>

現在在我的fangate(index.php)中,我這樣做:

<?php 
header('P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"');
header("Set-Cookie: SIDNAME=ronty; path=/; secure");
header('Cache-Control: no-cache');
header('Pragma: no-cache');
@session_start();
include('includes/facebook_data.php.php');


$sezione='fangate';
$pagina = '';
?>

<?php if(!LIKED): ?>
<!DOCTYPE HTML>
<html>
<head>
    <?php include("includes/head.php"); ?>
</style>
</head>
<body>
<?php include("includes/fb.php"); ?>
    <div id="fangate">
            <!-- your fangate -->
            <?php include("includes/footer.php");?>  
    </div>
</body>
</html>
<?php
elseif($redirect == "gotopage"):
    header('Location: page2.php');
else:
    header('Location: homepage.php');
endif;
?>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM