Reputation: 1676
I am new with hwi / HWIOAuthBundle with symfony2.3 and FOSUserBundle. I have already successfully install and this working fine with this doc https://gist.github.com/danvbe/4476697
But In on my twig page:
{% block content %}
<script>
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId : 'xxxxxxxxx', // App ID from the app dashboard
channelUrl : 'xxxxxxxxx', // Channel file for x-domain comms
status : true, // Check Facebook Login status
xfbml : true // Look for social plugins on the page
});
};
// Load the SDK asynchronously
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function fb_login() {
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
// connected
alert('Already connected, redirect to login page to create token.');
document.location = "{{ url("hwi_oauth_service_redirect", {service: "facebook"}) }}";
} else {
// not_authorized
FB.login(function(response) {
if (response.authResponse) {
document.location = "{{ url("hwi_oauth_service_redirect", {service: "facebook"}) }}";
} else {
alert('Cancelled.');
}
}, {scope: 'email'});
}
});
}
</script>
<p>
<a href="#" onclick="fb_login();">Facebook Connect Button (Dialog)</a>
</p>
{# Bonus: Show all available login link in HWIOAuthBundle #}
{% render(controller('HWIOAuthBundle:Connect:connect')) %}
{% endblock %}
This page is show facebook logo when I click then show me facebook login page and after login redirect to again login page bcoz I set default redirect to login But My problem is after login no show facebook logout button ?
What I am doing ?
Upvotes: 0
Views: 1339
Reputation: 626
Don't use the javascript way. Just give your path in tag.
<a href="{{ url("hwi_oauth_service_redirect", {service: "facebook"}) }}">Facebook Connect Button (Dialog)</a>
Upvotes: 2