简体   繁体   English

Facebook PHP SDK登录后添加权限

[英]Facebook PHP SDK adding permissions after login

I'm working on integrating the Facebook PHP SDK into a website I am building, and I have a question (maybe a problem, not sure yet...). 我正在将Facebook PHP SDK集成到正在构建的网站中,但我有一个问题(也许是个问题,尚不确定...)。

Initially I was planning on setting all the permissions in the initial login to allow my users to post to their feeds/page feeds through my site depending on which route they prefer, BUT I read on the FB SDK pages that requiring permissions at initial login that are not essential at that moment is bad practice. 最初,我打算在初始登录时设置所有权限,以允许用户根据自己喜欢的路线通过我的网站发布到其feed /页面feed中,但是我在FB SDK页面上阅读了在初始登录时需要权限的信息,那时还不是必需的,这是不好的做法。

My question is how do you add more permissions later using the PHP SDK? 我的问题是,以后如何使用PHP SDK添加更多权限? I scoured the internet for two days now looking for an example, and haven't been able to find one. 我在互联网上搜寻了两天,以查找示例,但是找不到一个示例。 Maybe I am looking in the wrong places. 也许我找错地方了。 I don't know. 我不知道。 I just haven't had any luck. 我只是没有运气。

My thought is that you check if the permission is set, and if not, log the user in with that permission, and use the new access token. 我的想法是,您检查是否设置了权限,如果没有设置,请使用该权限登录用户,然后使用新的访问令牌。 The issue for me is that doing it this way, I will have to write the form data to the session, then call it back when the FB login sequence is done. 对我来说,问题在于这样做,我将不得不将表单数据写入会话,然后在完成FB登录序列后将其回调。

Is my thinking correct, or is there a way to do this better? 我的想法是正确的,还是有办法更好地做到这一点? Should I just stack all the permissions right off the bat, or should I do it the way Facebook suggests? 我应该立即堆积所有权限,还是应该按照Facebook的建议进行操作?

The whole reason that my site is using facebook is to allow users to automatically share their posts (it is an art site) when they upload a piece to the site, instead of uploading a piece then having to go to that piece and click a share button on the page. 我的网站使用Facebook的全部原因是允许用户在将作品上传到网站时自动分享他们的帖子(这是一个艺术网站),而不是上传一件作品然后必须转到该作品并单击共享页面上的按钮。

Hopefully this rambling makes sense! 希望这次漫谈是有道理的!

My question is how do you add more permissions later using the PHP SDK? 我的问题是,以后如何使用PHP SDK添加更多权限?

Same way, as you asked for the initial permissions: 与您要求的初始权限相同:

By calling the login dialog again, with those additional permissions in the scope . 通过再次调用登录对话框,并在scope具有这些附加权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM