第一次在 Coldfusion 中使用我的 FB 应用程序时出现不需要的 Facebook 按钮

发布于 2024-11-01 20:54:31 字数 2457 浏览 1 评论 0原文

我正在玩 facebook 应用程序,使用 Coldfusion 将它们制作在 iframe 中。 以下是我的应用程序的网址 http://apps.facebook.com/firstones/

而不是直接进入权限页面,进入如下图所示页面。 我第一次使用该应用程序时得到的视图

点击那个大的“Facebook”按钮后,它会询问申请允许。一旦获得权限,它就会访问我托管该应用程序的网站,而不是仅在 Facebook 中打开它。

以下是我的画布网址的代码 [http://www.dkyadav.com/firstOnes/auth /]

index.cfm

<cfparam name="client_id" default="1234"> <!---same as app_id --->
<cfparam name="redirect_uri" default="http://www.dkyadav.com/firstOnes/auth/">
<cfparam name="redirect_uri_final" default="http://www.dkyadav.com/firstOnes/">
<cfparam name="scope" default="user_education_history,user_hometown,friends_education_history ">
<cfparam name="client_secret" default="56789"> <!---- App_secret key ---->


<cfif not isdefined('url.code')>
    <Cflocation url="https://www.facebook.com/dialog/oauth?client_id=#client_id#&redirect_uri=#redirect_uri#&scope=#scope#" >

<Cfelse>
    <Cfif isdefined('url.error')>
        <Cfoutput>
            #url.error#<br />
            Access denied.
        </Cfoutput>
    <cfelse>
        <cfoutput>#url.code#<br />
            <cfhttp url="https://graph.facebook.com/oauth/access_token" result="token">
                <cfhttpparam name="client_id" value="#client_id#" encoded="no" type="url">
                <cfhttpparam name="redirect_uri" value="#redirect_uri#" encoded="no" type="url">
                <cfhttpparam name="client_secret" value="#client_secret#" encoded="no" type="url">
                <cfhttpparam name="code" value="#url.code#" encoded="no" type="url">
            </cfhttp>
            <cflocation url="#redirect_uri_final#?#token.filecontent#" addtoken="no">
        </cfoutput>
    </Cfif>
</cfif>

以及 http:// www.dkyadav.com/firstOnes/index.cfm 我寻找 access_token 并拥有我的应用程序的其余部分。

我只在第一次运行时才执行上述操作。一旦其许可获得批准,它就会按预期正常工作。

您可以尝试自己运行此应用http://apps.facebook.com/firstones/ 请帮助并让我知道我实际上缺少什么。谢谢!!

I am playing around with facebook application, making them in iframe using coldfusion.
Following is the url of my app http://apps.facebook.com/firstones/

Instead of going directly going to the permissions page, it goes to the page shown below in picture.
View that I get when use the application first time

And after clicking on that big 'Facebook' button it goes to ask for applications permission. And once permissions are granted it takes to my website, where I have hosted the application, instead of opening it in Facebook only.

Following is the code of my canvas url [http://www.dkyadav.com/firstOnes/auth/]

index.cfm

<cfparam name="client_id" default="1234"> <!---same as app_id --->
<cfparam name="redirect_uri" default="http://www.dkyadav.com/firstOnes/auth/">
<cfparam name="redirect_uri_final" default="http://www.dkyadav.com/firstOnes/">
<cfparam name="scope" default="user_education_history,user_hometown,friends_education_history ">
<cfparam name="client_secret" default="56789"> <!---- App_secret key ---->


<cfif not isdefined('url.code')>
    <Cflocation url="https://www.facebook.com/dialog/oauth?client_id=#client_id#&redirect_uri=#redirect_uri#&scope=#scope#" >

<Cfelse>
    <Cfif isdefined('url.error')>
        <Cfoutput>
            #url.error#<br />
            Access denied.
        </Cfoutput>
    <cfelse>
        <cfoutput>#url.code#<br />
            <cfhttp url="https://graph.facebook.com/oauth/access_token" result="token">
                <cfhttpparam name="client_id" value="#client_id#" encoded="no" type="url">
                <cfhttpparam name="redirect_uri" value="#redirect_uri#" encoded="no" type="url">
                <cfhttpparam name="client_secret" value="#client_secret#" encoded="no" type="url">
                <cfhttpparam name="code" value="#url.code#" encoded="no" type="url">
            </cfhttp>
            <cflocation url="#redirect_uri_final#?#token.filecontent#" addtoken="no">
        </cfoutput>
    </Cfif>
</cfif>

And in http://www.dkyadav.com/firstOnes/index.cfm I look for access_token and have rest of my application.

I does the above said things only for the first time it run. Once its permission get approved, it works normally as expected.

You can try out this app running yourself http://apps.facebook.com/firstones/
Please help and let me know what I am actually missing. Thanks!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冷情妓 2024-11-08 20:54:31

我认为你遇到的问题是你在 Facebook 上的初始显示页面实际上是从 iframe 中爆发出来的。

您可以在 http://www.dkyadav.com/firstOnes/index.cfm 上看到 Javascript 的操作fbLogin() 函数中:

top.location.href = "https://graph.facebook.com/oauth/authorize?...

top 指的是窗口层次结构顶部的窗口,在您的情况下,这意味着实际的 Facebook 主页,其中包含iframe 在里面。

希望有帮助!

I think the problem you have is that your initial display page on Facebook is actually bursting out of the iframe.

You can see the Javascript doing that on http://www.dkyadav.com/firstOnes/index.cfm in the fbLogin() function:

top.location.href = "https://graph.facebook.com/oauth/authorize?...

top refers to the window at the top of your window hierarchy which in your case will mean the actual Facebook home page with the iframe in it.

Hope that helps!

像极了他 2024-11-08 20:54:31

我想我不需要 access_token,我只需要通过解码将 client_id 提交到“https://www.facebook.com/dialog/oauth....”得到的结果得到的 oauth_token

下面是我的代码我正在使用:

<cfif isdefined('signed_request')>
    <cfoutput>
        <cfset b64 = signed_request>
        <!--- Split the param by the . --->
        <cfset raw_str = ListGetAt(b64, 2, ".")>
        <cfset res = Len(raw_str) % 4>
        <cfif res eq 2>
             <cfset raw_str &= "==">
        <cfelseif res eq 3>
             <cfset raw_str &= "=">
        </cfif>
        <!--- Base 64 Decode --->
        <cfset result = ToString(BinaryDecode(raw_str, "Base64"))>
        <!--- String to JSON --->
        <cfset json = DeserializeJSON(result)>

        <cfif StructKeyExists(json,'oauth_token')>

        <Cfset at = json.oauth_token>

            <cfhttp url="https://graph.facebook.com/me/friends?access_token=#at#" result="newsFeed" />

            <cfif IsJSON(newsFeed.filecontent)>
                <cfset cfData=DeserializeJSON(newsFeed.filecontent)>
                <cfdump var = #cfData#>
            <cfelse>
                filecontent not in json format   
            </cfif>
        <cfelse>
            <script>
                top.location.href='https://www.facebook.com/dialog/oauth?client_id=12345XXX&redirect_uri=http://apps.facebook.com/test_app/&scope=read_stream,email'
            </script>
        </cfif>

    </cfoutput>
</cfif>

I think I dont need access_token, I just need oauth_token that I get by Decoding the result I got from submitting my client_id to 'https://www.facebook.com/dialog/oauth....'

Below is the code that I am using:

<cfif isdefined('signed_request')>
    <cfoutput>
        <cfset b64 = signed_request>
        <!--- Split the param by the . --->
        <cfset raw_str = ListGetAt(b64, 2, ".")>
        <cfset res = Len(raw_str) % 4>
        <cfif res eq 2>
             <cfset raw_str &= "==">
        <cfelseif res eq 3>
             <cfset raw_str &= "=">
        </cfif>
        <!--- Base 64 Decode --->
        <cfset result = ToString(BinaryDecode(raw_str, "Base64"))>
        <!--- String to JSON --->
        <cfset json = DeserializeJSON(result)>

        <cfif StructKeyExists(json,'oauth_token')>

        <Cfset at = json.oauth_token>

            <cfhttp url="https://graph.facebook.com/me/friends?access_token=#at#" result="newsFeed" />

            <cfif IsJSON(newsFeed.filecontent)>
                <cfset cfData=DeserializeJSON(newsFeed.filecontent)>
                <cfdump var = #cfData#>
            <cfelse>
                filecontent not in json format   
            </cfif>
        <cfelse>
            <script>
                top.location.href='https://www.facebook.com/dialog/oauth?client_id=12345XXX&redirect_uri=http://apps.facebook.com/test_app/&scope=read_stream,email'
            </script>
        </cfif>

    </cfoutput>
</cfif>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文