Facebook和QUOT;扇形闸门"用C#/ asp.net

编程入门 行业动态 更新时间:2024-10-26 03:32:16
本文介绍了Facebook和QUOT;扇形闸门"用C#/ asp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

问题是:1)Facebook的似乎与它是如何使开发人员可以用它(FBML,iFrame的,不同版本的SDK)和2)一切我找到的是PHP或Javascript和我有那些没有经验的相互作用,因而流体。我所要做的似乎SOOO简单,我不能相信没有一个简单的方法来做到这一点。

The problem is that 1) Facebook seems so fluid with how it allows developers to interact with it (FBML, iFrame, different versions of SDKs) and 2) Everything I find is either PHP or Javascript and I have NO experience with those. What I am trying to do seems sooo simple, and I can't believe there isn't an easy way to do this.

我有什么:

  • 我用Visual Studio 2010中创建一个简单的Web应用程序(asp/C#),要求用户输入一些信息(姓,名,电子邮件等)。我有一个有按钮调提交,点击后,输入的数据保存到数据库中。我有这个托管在GoDaddy的(我知道,我知道...嘿嘿)和它的作品就好了。这里没有问题。

  • I used Visual Studio 2010 to create a simple web application (asp/C#) that asks the user for some info (first name, last name, email, etc.). I have a button on there called "Submit" that, when clicked, saves the entered data into a database. I have this hosted on GoDaddy (I know, I know...heh) and it works just fine. No problem here.

我创建一个使用iFrame的啄所以,基本上我有一个显示上面提到的我的web应用程序在Facebook上一个新的标签是Facebook应用。这工作也没关系。该卡是存在的,Web应用程序是存在的,并且用户可以输入数据,并将其保存到数据库中。这里没有问题。

I created a "Facebook App" that uses the iFrame thingy so that basically I have a new tab on Facebook that displays my web app mentioned above. This works fine too. The tab is there, the web app is there, and users can enter the data and it is saved to the database. No problem here.

我想要什么:

  • 我要的Web应用程序(通过Facebook应用程序中显示的东西),只显示数据输入部分,如果用户当前喜欢Facebook的实体。我不希望要问权限。我只是想知道,如果他们是公司的Facebook页面,他们拥有这个应用程序的粉丝。所以,我需要在这里两件事情,下面我伪code所示:

第1部分(检查用户是否已经是一个风扇):

Part 1 (check if user is already a fan):

If (user is fan) { Show data entry area (unhide it) } else { Show "Click the like button to see more options" }

第2部分(监听象事件)

Part 2 (listen for "like" event)

WhenLikeButtonPressed() { Show data entry area (unhide it) }

我见过的东西,关于可见连接,C#SDK,edge.create等,但我不能让元首或它的尾巴。我不介意把在Javascript或PHP,如果有人能告诉我确切的说,扇形闸门傻瓜的步骤。拜托,我在这里要疯了: - (

I've seen stuff about "visible to connection", C# sdk, edge.create, etc. but I just can't make heads or tails of it. I don't mind putting in Javascript or PHP if someone could please give me exact, "Fan Gate for Dummies" steps. Please, I'm going crazy over here :-(

推荐答案

关键是是signed_request,Facebook的职位,以您的应用程序,当用户访问该页面。它包含关于用户是否喜欢该网页的数据。你不应该需要担心实际的标签FB页面上醒目的边缘事件,因为它得到的,当用户重新加载喜欢/ unlikes的页面。

The key is is the signed_request that Facebook posts to your app when the user accesses the page. It contains the data on whether or not the user likes the page. You shouldn't need to worry about catching edge events on an actual tab FB page as it get's reloaded when the user likes/unlikes the page.

您需要取消code。与您的应用程序的秘密,以获得类似信息的签名的请求。有提供了PHP的例子,但我敢肯定,有一点谷歌的帮助,你可以找到为signed_request为asp/c德#code的信息。

You'll need to decode the signed request with your app secret to get the like info. There are examples provided for PHP but I'm sure with a little google help you can find decode info for the signed_request for asp/c#.

下面是PHP的德code,以供参考:

Here's the php decode for reference:

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

和链接 developers.facebook/docs/authentication/signed_request/ 之类的信息将被包含在页面变量

and the link developers.facebook/docs/authentication/signed_request/ the like info will be contained in the page variable

更多推荐

Facebook和QUOT;扇形闸门"用C#/ asp.net

本文发布于:2023-05-25 10:52:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/226584.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:扇形   闸门   QUOT   Facebook   asp

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!