问题描述
|
我正在玩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/
请帮助,让我知道我实际上在想什么。谢谢!!
解决方法
我认为您遇到的问题是,您在Facebook上的初始显示页面实际上已爆出iframe。
您可以在
fbLogin()
函数中的http://www.dkyadav.com/firstOnes/index.cfm上看到该Javascript:
top.location.href = \"https://graph.facebook.com/oauth/authorize?...
“ 3”是指窗口层次结构顶部的窗口,在您的情况下,是指其中包含iframe的实际Facebook主页。
希望有帮助!
,我想我不需要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>