- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有人知道如何自定义/更改 FosFacebook 登录按钮的图像吗?
{{ facebook_login_button({'autologoutlink': true}) }}
并在整页 Facebook 登录上重定向,而不是在弹出窗口上重定向。
最佳答案
这使用了 twig helper 并使用 facebook sdk js 渲染带有 '' 符号的模板。
如果您需要重定向到登录页面,请使用 html 链接,从 php facebook sdk 调用方法“getLoginUrl”
您可以通过FOSFacebookBundle注册的服务'fos_facebook.api'
访问它
更新了代码示例
这是我用来通过 facebook 'frictionless' 登录的 JavaScript 代码
<script>
//scopes string stored as container parameter
var fb_scope='{{ facebook_scope }}';
//connected in sf2 app ?
{% if app.user %}
var isLogged=true;
{% else %}
var isLogged=false;
{% endif %}
//var to store fb status
var fb_connected = false;
function onFbInit() {
if (typeof(FB) != 'undefined' && FB != null ) {
// fetch the status on load
FB.getLoginStatus(handleSessionResponse);
//my facebook connect link
$('a.facebook_connect').on('click', function(e) {
FB.login(function(response) {
if (response.authResponse) {
checkAccount();
} else {
onAuthRefusal();
}
}, {scope: fb_scope});
e.preventDefault();
});
//my logout link
$('#logout').on('click', function(e) {
FB.logout(null);
});
//want to distinguish three status states
FB.Event.subscribe('auth.statusChange', handleSessionResponse);
}
}
function handleSessionResponse(response) {
if (response.status === 'connected') {
// the user is logged in and has authenticated your
// app, and response.authResponse supplies
// the user's ID, a valid access token, a signed
// request, and the time the access token
// and signed request each expire
var uid = response.authResponse.userID;
var accessToken = response.authResponse.accessToken;
var expiresIn = response.authResponse.expiresIn;
//already logged in sf2 app
if(!isLogged){
checkAccount();
}
fb_connected = true;
} else if (response.status === 'not_authorized') {
// the user is logged in to Facebook,
// but has not authenticated your app
fb_connected = false;
} else {
// the user isn't logged in to Facebook.
fb_connected = false;
}
}
function checkAccount(){
//route defined in your security.yml ( check_path value in your fos_facebook firewall )
top.location.href = '{{ path('_security_check_facebook' ) }}';
}
function onAuthRefusal(){
//message, special page ?
console.log('refused authentification, message to display ?');
}
</script>
{{ facebook_initialize({'xfbml': true, 'fbAsyncInit': 'onFbInit();', 'frictionlessRequests' : 'true'} ) }}
我还定义了一个重定向到 facebook auth 的路由 (/login/facebook )
//controller action for /login/facebook pattern
function loginFacebookAction()
{
//get facebook api service registered by FacebookBundle
$api = $this->container->get('fos_facebook.api');
//get scope provided in url or default
$scope = $this->container->get('request')->get('scope', 'publish_stream');
//generate call url that use facebook check_path (used by FacebookBundle for authentification)
$callback = $this->container->get('router')->generate('_security_check_facebook',array(), true);
$redirect_url = $api->getLoginUrl(array('scope' => $scope, 'redirect_uri' => $callback));
return new RedirectResponse($redirect_url);
}
就是这样!
关于facebook - 自定义 Facebook FOSFacebookBundle 登录按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14623778/
我在实现 FOSFacebookBundle 时遇到了大问题。 我按照文档进行操作并遇到以下情况:* 当用户点击登录时,会出现一个弹出窗口* 用户授予应用程序权限后,FB按钮将被更改(注销) 但是,我
我有一个 symfony 应用程序,它提供 RESTful API(用于移动应用程序)并具有后端管理。 我可以通过facebook成功登录后端,但是我应该如何允许通过RESTful API登录? 最佳
我在我的项目中使用 FOSUserBundle 和 FOSFacebookBundle(对于版本 SF 2.0.x)。此外,我按照 FOSFacebookBundle 文档中的描述实现并自定义了 Fa
我正在尝试设置 FOSFacebookBundle 和 FOSUserBundle,以便用户可以使用注册帐户或 Facebook 帐户登录。 相关代码如下: config.yml: fos_user:
有人知道如何自定义/更改 FosFacebook 登录按钮的图像吗? {{ facebook_login_button({'autologoutlink': true}) }} 并在整页 Facebo
我有一个无法解决的特殊用例。当用户点击 Facebook Connect并在我的数据库中找到类似的电子邮件。我想问一下用户这个账号是不是他的。 如果答案是肯定的,他需要连接他的帐户,然后添加Faceb
FOSUserBundle 对我正在从事的项目很有用。但我正在尝试嵌入 FOSFacebookBundle 并使其与 一起使用FOSUserBundle . 为此,我建立了自己的 Acme\MyBun
我是一名优秀的程序员,十分优秀!