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');
}
});
Related
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!
I need to get post-id after user clicks on the share button. My code so far:
$("#share").click(function(e) {
e.preventDefault;
FB.ui({
method: 'share',
href: 'developers.facebook.com',
}, function(response){
if(response && !response.error_code) {
console.log(response); // => []
} else {
alert('err');
}
});
});
After content is successfully shared, the response I get is an empty array with no data. How can I get the post-id of share post?
Check out the docs for information about the response:
Only available if the user is logged into your app using Facebook and has granted publish_actions. If present, this is the ID of the published Open Graph story.
Meaning, you will only get the post-/object-id if the user is authorized with the publish_actions permission.
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.
So I've been trying to implement a Fb method feed so that people can share songs from my website. But it doesn't work.
It pops up a loading gif in the dialogue and thats it. No error nothing. I've wasted a lot of time trying to figure this out but haven't been able to.
Here's the code,
share_obj = { method: 'feed',
link: "", redirect_uri: "",
picture: ",
name: "",
caption:"" ,
description: ""
}; FB.ui({method: "permissions.request", "perms": 'publish_stream'},
callBack);
function callBack(response) { if(response["perms"]=="publish_stream") { var obj = share_obj; FB.ui(obj,callback_share); } } function callback_share(response) { }
Does it have something to do with Facebook app migrations or app permissions?
So turns out, there s no need to ask for user permissions when invoking the Fb.ui method.
Permissions are only required when you intend to publish stories via the graph API.
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¬if_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)