Facebook Request 2.0 - facebook

I am kind of confused on how to use the new facebook request dialog box. Using the below mentioned function opens a box and I am able to send the request to the user who receives it. But when the user clicks on the request nothing happens instead the user is redirected to an internal link:
http://www.facebook.com/?request_ids=105890902828361%2C105893002828151%2C105899456160839%2C105902046160580%2C105904092827042&notif_t=app_request
How to resolve the issue? (Canvas Page not defined in Settings but Canvas Url is)
function requestsDialog()
{
FB.ui({
method: 'apprequests',
message: 'Here is a new Requests dialog...',
title: 'example',
data: 'trackinginfo'
},
function(response) {
if (response) {
alert('Request was sent.');
} else {
alert('Request was not sent.');
}
}
);
};

You need to specify a Canvas Page. For example, if your canvas page is:
http://apps.facebook.com/test_application
Then the URL that user will go to when clicking on the request will be:
http://apps.facebook.com/test_application?request_ids=12020393994,129193929392
At which point you can use the Graph API to look up what the requests are using the id (documentation here)

Related

how to send facebook message to multiple users using fb.ui

I want to send facebook message to multiple users and after sending message I want those user ids from dialog in response.
I searched that it is not possible only with method send so first I am using apprequests method and from this response I want to pass selected users to facebook send dialog.
Here is the code which I am using.
FB.ui({
method: 'apprequests',
message: "my app request message",
link: 'http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html',
}, function(response) {
if(response && response.hasOwnProperty('to')) {
var user_ids = [];
for(i = 0; i < response.to.length; i++) {
user_ids.push(response.to[i]);
}
console.log(user_ids);
fb_share(user_ids);
}
});
function fb_share(user_ids){
FB.ui({
method: 'send',
to: user_ids, //[862579587127634, 1571716563066056],
link: 'http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html',
});
}
But in this case when Message dialog box appears after inviting friends, it selects only one user not multiple users.
Please help me guys.
Thanks!

Canvas -> Base64 post to Facebook

I have implemented a pure javascript function for sharing canvas content to an user's facebook wall. The implementation works, but the problem is:
Facebook does not approve the app, stating after review:
"publish_actions on Web - Your app's users must enter all content
in the user message field. Don't auto-populate the message field with
any content, including links and hashtags, even if you allow users to
edit the content before sharing. Watch this informational video for
more information, and see Platform Policy 2.3"
Afaik, there is no way to pass a base64 object through the FB.ui feed share dialogue with client side javascript only.
Question: Any workarounds or other ways go get a client side only canvas -> facebook share implementation that is passed by the Facebook app approval process?
The current implementation is as follows:
document.getElementById('facebook-link').onclick=function(){
FB.login(function (response) {
if (response.authResponse) {
window.authToken = response.authResponse.accessToken;
PostImageToFacebook(window.authToken);
} else {
}
}, {
scope: 'publish_actions'
});
};
function PostImageToFacebook(authToken) {
var imageData = canvas.toDataURL("image/png");
try {
blob = dataURItoBlob(imageData);
}
catch (e)
{
console.log(e);
}
var fd = new FormData();
fd.append("access_token", authToken);
fd.append("source", blob);
try {
$.ajax({
url: "https://graph.facebook.com/me/photos?access_token=" + authToken,
type: "POST",
data: fd,
processData: false,
contentType: false,
cache: false,
success: function (data) {
console.log("success " + data);
},
error: function (shr, status, data) {
alert.log("error " + data + " Status " + shr.status);
},
complete: function () {
console.log("Posted to facebook");
$('#facebook-link').text('Ferdig delt :)').removeClass( "inProgress" );
}
});
} catch (e) {
console.log(e);
}
}
The implementation does not append any text, making me wonder why it does not comply with the Facebook Platform Policy section 2.3.
I had the same problem in an application. Although we have chosen to use the database, I believe it has a solution to your problem.
Really has no way to share a Base64 code by FB.Ui
But as the policies of Facebook, you are not required to use it.
You can create a custom dialog window for the user to view the image that is being posted and enter/confirm the message, and posting after this action.
As the explanatory video from Facebook, the message posted by the user can not be changed, then it should be approved without problems.

Facebook share dialog not closing after feed post

I have a feed post JS as follows.
var feedObj = {
method: 'feed',
link: link,
picture: imagelink,
name: name,
caption: caption,
description: description,
redirect_uri: "http://"+(window.location.host)+"/",
next:null,
app_id: appid,
actions: [
{ name: text, link: link }
]
};
function callback(response) {
if(response){
}
}
facebook.ui(feedObj, callback);
How do I make sure the feed dialog that clicked to post closes automatically?
I have noticed that the callback is not fired always and this attempt below does not work always
function callback(response) {
if(response){
facebook.Dialog.remove(facebook.Dialog._active);
}
}
I have got a simple trick to close this dialog box. It is not a good way to do this type of work but it just worked fine for me.
Firstly you have to create a page on your server (e.g. closewindow.aspx) and paste this code in your page's body part.
<script src="js/jquery.js" type="text/javascript"></script>
<script>
$().ready(function() { window.close(); });
</script>
Than set redirect_uri parameter property to this page, like :
redirect_uri=http://www.yousitename.com/closewindow.aspx
Now this time in dialog box, this page will be called as redirecturl and the dialog will be closed automatically on page load.
I know this may be tricky but you know how it feels when got this working.
According to the documentation, next is not a parameter.
I understood that with redirect_uri callback is not being called.
Since redirect_uri is supported by most sdks you need not use it.
DEMO
Hope this helps

Redirect to page with add page tab dialog

Facebook recently notified they are deprecating support for app profile pages.
Apps created after Dec 10th no longer have the app page option, together with the
"add to my page" functionality, and must use the new Add page tab dialog.
After the user selects which page to add the application to, is there any way to
redirect the user to the selected page?
Similar functionality existed in the "old" add to page dialog, e.g.
https://www.facebook.com/add.php?api_key=MY_ADD_ID&pages=1
Activating the dialog with a response function seems to bring no result.
`
// Add app to page
function addToPage() {
// calling the API ...
FB.ui({
method: 'pagetab',
redirect_uri: 'MY_URL',
},function(response) {
alert(response);
});
}
`
So, two questions:
a) Is there any possibility for the app using the dialog to "know" which page was selected?
b) Is there any way to redirect the user to the selected page.
Thx!
<script type="text/javascript">
function addToPage() {
// calling the API ...
FB.ui(
{
method: 'pagetab'
},
function(response) {
if (response != null && response.tabs_added != null) {
$.each(response.tabs_added, function(pageid) {
alert(pageid);
});
}
}
);
}
</script>
Use above code...you will get page id of pages selected by the user
but what if the user has a custom name for its page.
i modify devson.. code a bit
FB.ui(
{
method: 'pagetab',
redirect_uri: '',
},
function(response) {
if (response != null && response.tabs_added != null) {
$.each(response.tabs_added, function(pageid) {
FB.api(pageid, function(response) {
alert('redirect to ' + response.link);
});
});
}
}
);
This used to be simple, using the facebook UI.("Add to My Page") Unfortunately facebook removed this.
You can add it using www.facebook.com/dialog/pagetab?app_id=YOUR_APP_ID&next=YOUR_URL
I put this an html and publisched it below. Just visit, enter your app params, hit submit, and our done.
http://www.jibecompany.com/2012/add-a-facebook-page-tab-application-to-your-page

check if user share on facebook application

is it possible in an iframe applications check if the user share something successfully. may i get the request id if it is successfully shared so if it is shared i want to make the share button's visible false to that user and the user earns some points if the share is successfull
so is it possible to know and check it?
i am using c# but it is ok for javascript code
thanks
using the Javascript SDK you should be able to get that information.
FB.ui({
method: 'apprequests',
message: 'Your message here',
title: 'App Request',
},
function (response) {
if (response) {
var numberSelected = response.to.length;
var firstIdSelected = response.to[0];
} else {
alert('canceled');
}
});