Invite friends dialog - facebook

I have an invite dialog on my page:
<a href="#" onclick="sendRequestToManyRecipients(); return false;" >xx</a>
<script language="javascript" type="text/javascript">
FB.init({appId : 'myappid', status : true, cookie : true, oauth: true});
function sendRequestToManyRecipients() {
FB.ui({ method: 'apprequests', message: 'xxx'},requestCallback);
}
function requestCallback(response) {
// Handle callback here
}
</script>
When the invited user clicks the invite, he gets linked to the app, but I want the user to get redirected to a page like http://www.facebook.com/pages/xxx/xxx?sk=app_xxxx.
How can I do that?

That's not possible without some custom coding - the requests interface exists to drive traffic to apps on facebook, not to page tabs, there's no way to have Facebook send users to a tab when they accept the request.
You could just implement something on your canvas landing page that redirects users back to a page tab based on the information in the request as a workaround.

previous version of the apprequest which is request-form this was possible: How can I include a link in a FB app request?
However current version of apprequest : facebook guys lets only redirect to your app: https://apps.facebook.com/yourapp
#Vihay comments helps this custom workaround to redirect to page.
Hoping next version apprequests, facebook enables redirect to links within the fb app.

Agree with previous answers. Facebook will redirect to your app, which is just a Facebook wrapper around a page you can provide. That page can then use a client-side redirect to whatever page you'd like (like what Klout does).

Related

Invite friends to like a Facebook Fan Page

In my website I want to integrate the "Invite your friends to like this Page" similar to the Facebook Fan Page(Any), where people can search a friend and send an invite to like a page, after receiving and clicked that notification the user will be redirected to the Facebook Fan Page.
This what I do, by adding an App and Creating a Facebook Canvas in the Developer Tools and with this piece of code in my website:
window.fbAsyncInit = function() {
FB.init({
appId : '577325869064730',
cookie : true,
xfbml : true,
version : 'v2.2'
});
};
function sendInvite() {
FB.ui(
{
method: 'apprequests',
message: "I am inviting you to like my page"
},
function(response) {
console.log(response);
}
);
}
It seems do the work, but the problem is it is not really the one I'm expecting because, It's not redirecting to the my Facebook Fan Page and the Facebook canvas URL only allowed a secure URL ("https") and doesn't allow the URL Facebook.
Is there a workaround for the redirection of the URL, rather than redirect to the declared URL in the Facebook canvas it should be pointed to my Facebook Fan Page. And the result should be the FULL Page of the Facebook Fan Page not in the Canvas.
Can this be done?
apprequests are for inviting friends to a game app on Facebook Canvas, not for inviting them to a Page (APP requests, hence the name). It will always redirect to the Canvas Page.
Better use the Send Dialog or Share Dialog. Of course you donĀ“t need https for those.
So far I was able to find a way to redirect it on the Facebook Fan Page, I just don't know if this is the correct solution:
In the website header, the one I declared in the Facebook Canvas URL:
I inserted this code:
<script type='text/javascript'>
top.location = "www.facebook.com/fanpage"
</script>
It is now redirecting to the Facebook Fan Page.

How do you create a mobile friendly Like Gate for a Page on Facebook?

I've put a Like Gate on a few of my Facebook Pages and I'm getting a lot of complaints saying that people can't access the content via their mobile device since the mobile version of the facebook website, and the facebook apps for ios/android, don't support tabs on Facebook.
I see there are services out there (I'm not sure how legit they are) that offer a way to create a mobile like gate for your page tab, but I can't find any documentation on how they do it. These services are not suitable for me, because the content on my tab is custom and dynamic.
So, how can I create a interstitial page for a mobile page that requires the visitor to have liked my Page on Facebook before they can proceed? This has to work for new users, as well as existing users who re-visit the tab and without requiring an install to an application.
Thanks!
One approach you can take for a mobile site is to check that the user has liked the page in question via the JS SDK.
If you have a logged-in user to your application, you can Subscribe to the authResponseChange FB event within your JS SDK initialization, or call a function directly to make an API request to verify if the user is a fan of your page.
In your initialization:
FB.init({appId: YOUR_FB_APP_ID_HERE });
window.fbAsyncInit = function() {
// React to a user clicking an on-page Like button:
FB.Event.subscribe("edge.create", verifyUserLikesPage);
}
You can verify that the user likes the appropriate page in the like handler:
function verifyUserLikesPage() {
FB.api("/me/likes/"+FBID_OF_PAGE_TO_ENSURE_THEY_LIKE, function(apiResponse){
if (apiResponse.data && apiResponse.data.length > 0)
// User likes the page. Enabled them to proceed
else
// User does not like the page. Require they click Like.
}
}
More information on the edge.create subscribe via JS available here: https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/

Logging in through Facebook, if not registered, should redirect to registration page

My site has the option of registering with and without facebook. When you register with facebook though, extra information is needed. This is fine, as I use fb:registration and specify extra fields.
However, the problem is, when a user comes to the site and hasn't registered, sees the facebook login button and clicks it, the link brings them to facebook to login and the app is registered and bypasses the registration form I have.
I there a way to redirect a non-registered user that is not logged in with facebook to a registration page instead of adding the app?
You can add the registration-url parameter to the login button as documented in the Login + Registration Flows section.
<fb:login-button
registration-url="yoururl" />
This isn't documented so I don't know if it will continue to work but if your using the HTML5 version of the login button then you can use:
<div class="fb-login-button" data-registration-url="yoururl">Login with Facebook</div>
Not 100% sure i understood you but..
Going on the assumption that you only want users who have an active FB browser session and have authorized the use of your application with their account to see your login button/a particular page you could try this right after your FB.init:
FB.getLoginStatus(function(response) {
if(notLoggedIntoYourSite && response.status != 'connected') {
// Redirect user or hide login button
}
})
Ref: http://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus/

Facebook to check "like" on fan page

I noted there is a link to generate "like button" code at :
http://developers.facebook.com/docs/reference/plugins/like/
However it wasn't act as the top of fanpage "like" button which will redirect users to another page if I setup to check the pages liked or not. Is there any other way that I can generate the button as the top of fanpage "like button" behavior or way of using the recent plugins like and redirect users once they liked the page?
Eric.
If you are using a XFBML like button then you can use the JavaScript SDK to detect likes by subcribing to the edge.create event using FB.Event.subscribe
FB.Event.subscribe('edge.create',
function(response) {
// Do redirect here
}
);
For more information on the Facebook JavaScript SDK please go here:
http://developers.facebook.com/docs/reference/javascript/

Facebook fb-login not redirecting back

I want to authenticate the user using facebook login credentials. Everything works, except for the fact that it does not redirect to the redirect_uri specified which I require to capture the signed_request. Any help is hugely appreciated.
Below is what I have
#fb-root
%script{:src => "http://connect.facebook.net/en_US/all.js"}
:javascript
FB.init({
appId:'my_client_id_from_the_app_i_created', cookie:true,
status:true, xfbml:true
});
%fb:login-button{:perms => "publish_stream", :redirect_uri => "#{facebook_signin_url}"}
Login using your facebook account.
Since you mention signed_request I assume that you are building a canvas or page tab app.
If so, I don't recommend that you use the login-button.
Rather, just redirect to the OAuth Dialog.
This creates a much better experience for the user.
See https://developers.facebook.com/docs/guides/canvas/#auth for step by step instructions.
If you are using the fb canvas the application will POST back to
the url set in the canvas url setting, or you can set the window
location using <%= fb_login_button('window.location =
"/users/link_user_accounts";')%>
redirect_uri is not a valid fb:login-button option, so means nothing to fb. If you are not using the canvas and this is a website, and you want to redirect after login, use the onlogin option(instead of the redirect_uri) to call javascript to post to the location you desire. Check out how this is done in the authlogic-facebook-connect gem: https://github.com/kalasjocke/authlogic_facebook_connect/blob/master/lib/authlogic_facebook_connect/helper.rb