Facebook - PopUp Invite Friend in iFrame application - facebook

I'm developing facebook game, that using iFrame.
How to show popUp invite Friend ?
Thanks so much

I'm assuming you're using the Javascript API within your iFrame. You can write some FBML to create the friend invitation dialog. See the example here:
http://developers.facebook.com/docs/guides/canvas/#requests
If you want a popup you may have to use the FB.ui method:
http://developers.facebook.com/docs/reference/javascript/FB.ui

You'll want to use the Requests Dialog.
http://developers.facebook.com/docs/reference/dialogs/requests/

Related

Facebook Invite Friends to app - Dialogs requests

I use this code for inviting facebook friends to app : http://pastebin.com/A4LkB8sF
FB.ui({ method: ‘apprequests’, message: ‘Facebook Promotion App’ });
Its working fine but if they click the Link in the FB notification bar they dont get linked directly to my page and app. Instead they are at a “step between”. The app is visible in an iframe with less than 810px and no like button.
This are the link parameters:
*/?fb_source=notification&request_ids=12345621890&ref=notif&app_request_type=user_to_user&notif_t=app_request*
Where is the problem? Why is FB not linking the user to the app in page directly?
I guess the solution is somewhere in the App settings maybe… but i dont know.
Please help me, is important ?
Specify redirect_uri also in the parameters list.

Opening Facebook dialogue box in the same page

I have been trying to implement the Facebook Feed Dialog as follows
<a href="http://www.facebook.com/dialog/feed?app_id=12345678&redirect_uri=http://example.com&link=http://example.com&message=Hi+wassup!">
But the problem is it is opening the link in a page, rather than a pop up box.
Pls help!
To do this as a dialog, you would need to use the Facebook Javascript SDK and call the FB.ui function using the 'feed' value for method.

Facebook Javascript SDK change friend selector submit button text

I'm trying to use the Facebook Javascript UI method to show a friend selector dialog. However, because my app doesn't actually send invites to the selected friends, the text of the submit button is "Send Requests" is very misleading. Is there anyway I can change this text while still using a Facebook API?
I'm using
http://developers.facebook.com/docs/reference/dialogs/requests/
and have also tried
http://developers.facebook.com/docs/reference/fbml/multi-friend-selector/
I think that including fb:req-choice into the FBML of your UI could do the trick.
Example code can be seen here:
Showing popup in the new Facebook JavaScript SDK

'Like' a page using Facebook Graph API

Using the Graph API I'd like to be able to have an authorized user "like" a page.
I tried posting the following
https://graph.facebook.com/${PAGE_ID}/likes?access_token=${ACCESS_TOKEN}
And I get an HTTP error 500 accompanied by "Invalid post_id parameter" in the JSON response body. Looks like the /likes resource is suited to liking a wall post and not a page. How do I get this to work with a page?
Facebook has announced support for liking URL's outside of Facebook by using the official built-in Like action. You need to have publish_actions permissions. The graph url for this is:
https://graph.facebook.com/[User FB ID]/og.likes?object=OG_OBJECT_URL&access_token=USER_ACCESS_TOKEN
However, you cannot use this to like a page on Facebook currently, as the documentation states:
For Facebook Pages or websites that do not integrate with Facebook
Authentication, developers should continue to use the Like button
social plugin.
Update June 2016
It's still not possible to like a page using Facebook API, as stated in the /{user_id}/likes documentation page about Creating/Updating/Deleting:
You can't perform this operation on this endpoint.
In previous versions the message was clearer (see the quote below), but the result is the same: it's not possible.
May 2014
The /{user-id}/likes documentation page States about Publishing Likes of Facebook Pages:
You can't publish using this edge, as it is not possible to like a Facebook Page via any API. You should use the Like Button if you want people to be able to like a page in your app.
This is the most obvious and clear statement that has been able to give me an answer to the question.
if your app is an open graph app, now you can like using the api, and no need for the button anymore.
https://developers.facebook.com/docs/opengraph/actions/builtin/likes/
If you want this functionality in a page tab or canvas page within facebook (say to allow for liking the page from within a likegated page), a work around you can involves what Tom Wells suggested in his reply to Luke. You first embed the iframe version of their like button on your page, and then simply listen for the edge.create event in your JS like so:
FB.Event.subscribe('edge.create',
function(response) {
alert('You liked the URL: ' + response);
// ...
}
);
In the callback, you can deal with with what happens when the user has liked the page, say like navigating away from the like-gate page, or showing liked-only content.
When the user clicks the iFrame like button, your JS code should receive the edge.create event assuming the iFrame was configured to point to the url of the page in question.
I believe this is not allowed except for specific partner sites, like yelp. The reason is security, you would be able to put some javascript on a page and have everyone that visits that page "Like"ing it without their knowledge.
See How do I "Like" a URL? on the Facebook Platform Developer Forum
You can like an object with its object id using Facebook api using the following piece of code
[FBRequestConnection startForPostWithGraphPath:[NSString stringWithFormat:#"/%#/likes",{object_id}] graphObject:nil completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
//do you customisation post like here
}];

Facebook Application Send Friend request using Facebook Api

I want to send Facebook friend invitations to some of our friends list without using FBML tags (<fb:request ....)
I am writing code in ASP.NET using fbServices.
How can I send friend requests without using FMBL tags?
Friend requests cannot be done through the Facebook API. The FBML fb:request-form tag is the only way to do this.
I spent a great deal of time looking, and finally came accross a very simple solution.
Using the Facebook Javascript API you can do a friend request with:
<script>
FB.ui(
{
method: 'friends.add',
id: fbid // assuming you set this variable previously...
},
function(param){
console.log(param);
// If they cancel params will show:
// {action:false, ...}
// and if they send the friend request it'll have:
// {action:true, ...}
// and if they closed the pop-up window then:
// param is undefined
}
);
</script>
The callback script can then simply performs an ajax call to your server where
you save info about the action, if needed.
You can test this by using the javascript console app on Facebook:
http://developers.facebook.com/tools/console
Paste in the script above, including the tags, or click the "Examples"
button on the bottom of the text area and find the "fb.ui — friends.add" example.
fb:request-form is now obsolete and will be deprecated eventually. The new way, announced on 27 January 2011, is the Requests Dialog.
Facebook does not allow you to programatically send friend requests.
I suggest taking a look at their API
Okay. Years later, things has changed:
https://developers.facebook.com/docs/reference/dialogs/
Dialogs provide a simple, consistent interface to provide social
functionality to your users. Dialogs do not require any additional
permissions because they require user interaction. Dialogs can be used
by your application in every context: within a Canvas Page, in a Page
Tab, in a website or mobile web app, and within native iOS and native
Android applications.
There are currently 7 Dialogs available for you to use:
- The Feed Dialog allows a user to post a story to their Timeline and to their friends' News Feeds
- The OAuth Dialog allows a user to authorize an application as part of an authentication flow.
- The Add Page Tab Dialog allows a user to add an application to a Facebook Page which they administer.
- The Friends Dialog allows a user to send a friend request to another user.
- The Pay Dialog allows a user to make a purchase using Facebook Credits.
- The Requests Dialog allows a user to send a request to one or more of their friends
- The Send Dialog allows a user to send a Facebook Message to one or more of their friends.
See also: https://developers.facebook.com/docs/requests/
You can send requests to friends without using FBML as follows
`FB.ui({
method: 'apprequests',
message: 'This is my applicaiton',
title: 'Application Request without FBML',
filters: 'all'
},
// Callback function returning the list of requestObj Ids
function(response){
}
);`
For more info you could refer
Wiki Page for apprequest graph API