使用 koala 签名的请求处理权限
我正在构建一个带有 Rails 和 koala 签名请求授权的画布应用程序,但我不知道我的方法是否正确。如何获得用户的权限?现在我正在做类似下面的代码的事情,但我知道这是错误的,因为当用户被重定向时,它必须在授予权限之前单击“访问 Facebook”按钮......
before_filter :parse_signed_request
def parse_signed_request
@oauth = Koala::Facebook::OAuth.new('callback')
@signed_request = @oauth.parse_signed_request(params[:signed_request])
if @signed_request["user_id"]
@graph = Koala::Facebook::GraphAPI.new(@signed_request["oauth_token"])
else
redirect_to @oauth.url_for_oauth_code(:permissions => "publish_stream");
end
end
I'm building a canvas app with rails and koala signed request authorization but I don't know if I'm doing the right way. How do I get permissions from the user? Right now I'm doing something like the code below but I know it's wrong because when the user is redirected, it has to click on the "Access Facebook" button before giving the permissions...
before_filter :parse_signed_request
def parse_signed_request
@oauth = Koala::Facebook::OAuth.new('callback')
@signed_request = @oauth.parse_signed_request(params[:signed_request])
if @signed_request["user_id"]
@graph = Koala::Facebook::GraphAPI.new(@signed_request["oauth_token"])
else
redirect_to @oauth.url_for_oauth_code(:permissions => "publish_stream");
end
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您无法重定向,只需发回脚本:
。
您可以在这里找到更多信息:http://developers.facebook.com/docs/guides/canvas /
You can't redirect, just send back a script:
<script type="text/javascript">top.location.href='...'</script>
.Here you can find more information: http://developers.facebook.com/docs/guides/canvas/
查看此博客文章奎拉。总结一下:是的,您可以使用 Ruby on Rails。这篇文章提供了一些入门代码以及关于要避免哪些已弃用的 API 的有用提示。
Check this blog post on Quora. To summarise: yes, you can use Ruby on Rails. The post provides some starter code and useful tips on which deprecated APIs to avoid.