Invite friends to like a Facebook Fan Page - facebook

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.

Related

Using the FB API, can you share a link, but serve an image that is not on the page

I can post a photo IF I had the time to get an app approved. I can share a link that pulls in a photo from THAT page. The goal is to post a link that goes to X, but the image is hosted somewhere else.
Is this possible?
Yes, it's possible by using the JavaScript SDK and the Share Dialog. For example, I can do the following, which shares a link but with a custom image, name and caption. It basically overwrites all the OG data on my page.
function fb_share() {
FB.ui( {
method: 'feed',
name: "Facebook API: Tracking Shares using the JavaScript SDK",
link: "https://www.webniraj.com/2013/05/11/facebook-api-tracking-shares-using-the-javascript-sdk/",
picture: "https://stackexchange.com/users/flair/557969.png",
caption: "Tracking Facebook Shares on your website or application is a useful way of seeing how popular your articles are with your readers. In order to tracking Shares, you must used the Facebook JavaScript SDK."
}, function( response ) {
// do nothing
} );
}
$(document).ready(function(){
$('button.share-btn').on( 'click', fb_share );
});
You can do the same thing in PHP if you have the publish_actions permission approved by Facebook. Both would produce the following result:
Source

Make link in Send Dialog to Facebook application?

Hi so I am making a Facebook app which uses the send dialog. I was wondering why it doesn't work when I put 'https://apps.facebook.com/APP_NAME/' as my link parameter. I want the link in the send message to be a link to my app but on the send dialog is appears as apps.facebook.com. Is there anyway to do this?
Edit: Yes sorry here is the code:
<script>
FB.init({appId: 'App_ID', xfbml: true, cookie: true});
function sendMessage(){
// assume we are already logged in
var token = FB.getAuthResponse().accessToken;
FB.ui({
method: 'send',
name: 'Test',
link: 'https://www.apps.facebook.com/APP_NAME',
description: 'This is a test',
picture: '',
display: 'iframe',
access_token: token
});
}
</script>
If you dont want the apps.facebook.com domain showing up in the caption for the post, you ca theren create a new page in your site. Set all the og meta tags to what you want to show up in the feed. The only other content in the page should just be a javascript redirect to your you canvas app. This way when FB scrapes your site, they get all the necessary data and when a user clicks on the link, the js redirects them to your app.
Also, there is not a "www" in the url for app canvas pages.

Multiple share button on one page or share website comments to facebook while adding

I have a website where there is comments systems. I want to add a comment to facebook while adding a comment to my website.
If it is not possible to add to Facebook while adding to my site is it possible to show share to facebook button with each comments so that clicking on it will share that comment on facebook. May be possible with fb.in?
Not 100% sure, but it sounds like you have your own comment system on your web site and that you'd like to auto-publish to FB the comment that someone makes on your own site.
You'd need to implement the Facebook SDK on your web site:
Have your user authorize your site using 'FB.login' with 'publish_stream' permission (see docs).
In your comment system code, after your user has entered in their comment, you can make a separate call to the Graph API to publish to the user's feed. For example, if using the Facebook Javascript SDK:
Following is the code:
var body = myJustEnteredComment;
FB.api('/me/feed', 'post', { message: body }, function(response)
{
if (!response || response.error)
{
alert('Error!');
}
});

Invite friends dialog

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).

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/