如何在Facebook上创建粉丝/喜欢的门? [英] How to create a fan / like gate on Facebook?

查看:77
本文介绍了如何在Facebook上创建粉丝/喜欢的门?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个简单的扇形门.在其中为无粉丝指定一个内容,为粉丝指定其他内容(如果他们按了赞"按钮).但是,当我在页面选项卡中运行该页面时,它不会返回已签名的请求,因此,我没有办法弄清楚该怎么做.有人可以发布教程或对此进行修复吗?至此,我得到了以下代码:

I am trying to create a simple fan/like gate. Where you specify one content for none fans and other content for fans (if they pressed the like button). However when I run the page in the page tab it does not return a signed request and thus there is no way for me to figure out how to do it. Can someone post a tutorial, or have a fix for this? At this point I got the following code:

index.php

<?php
require dirname( __FILE__ ) . '/../api/facebook.php';

// Create our application instance
// (replace this with your appId and secret).
$facebook = new Facebook(array(
  'appId'  => '112458478872227',
  'secret' => 'X',
  'cookie' => true
));

$signed_request = $facebook->getSignedRequest();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="nl">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

    <title>Home</title>
</head>
<body>

<?php 
if ( $signed_request['page']['liked'] ) 
{
    echo 'A fan';
}
else
{
    echo 'Not a fan yet.';
}
?>

</body>
</html>

链接:

http://www.facebook.com/talkieslifestylemagazine?sk=app_112458478872227

Faceook应用程序:

页面标签

  • Page Tab Name: Home
  • Page Tab URL: http://apps.talkiesmagazine.eu/facebook/home
  • Secure Page Tab URL :empty
  • Page Tab Edit URL : empty

推荐答案

看起来原始海报已切换为使用Wildfire的like gate应用.但是无论如何...

It looks like the original poster switched to using Wildfire's like gate app. But anyway...

您的服务器正在执行重定向,然后再运行脚本.如果您将代码放在例如 http://apps.talkiesmagazine.eu/facebook的文件夹中/home/index.php -但您指定 http://apps.talkiesmagazine.eu/facebook /home 作为您的网址-网络服务器将看到 http://apps.talkiesmagazine.eu/facebook/home 是一个文件夹,并重定向到 http://apps.talkiesmagazine.eu/facebook /home/.该重定向不会保留带有已签名请求的POST数据.您可以查看是否将 http://apps.talkiesmagazine.eu/facebook/home 放入您的浏览器,它将重定向到 http://apps.talkiesmagazine.eu/facebook/home/

Your server is doing a redirect before your script is run. If you put your code in a folder such as http://apps.talkiesmagazine.eu/facebook/home/index.php - but you specify http://apps.talkiesmagazine.eu/facebook/home as your url - the webserver will see that http://apps.talkiesmagazine.eu/facebook/home is a folder and redirect to http://apps.talkiesmagazine.eu/facebook/home/. That redirect doesn't preserve the POST data which carries the signed request. You can see if you put http://apps.talkiesmagazine.eu/facebook/home in your browser, it is redirected to http://apps.talkiesmagazine.eu/facebook/home/.

将标签页网址更改为 http://apps.talkiesmagazine.eu/facebook/home/将对其进行修复.

Changing your tab url to http://apps.talkiesmagazine.eu/facebook/home/ will fix it.

但是,Facebook要求您进行服务器设置,以通过https安全地提供您的应用程序,并将安全标签URL设置为该URL. Secure Page Tab URL为空,因此也需要对其进行更改以具有功能齐全的选项卡.

However, Facebook requires that you have your server setup for securely serving your app over https and set the secure tab url to that url. You have the Secure Page Tab URL empty, so that would need to be changed as well to have a fully functional tab.

这篇关于如何在Facebook上创建粉丝/喜欢的门?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆