FB.ui sharing app result help needed - javascript

I have a javascript game app added as a page tab, it is a memory game which counts the number of turns needed to solve the puzzle. can anyone help me how to share the variable which holds the result with FB.ui share dialog?
FB.ui({
method: 'share',
message: 'some message',
link: 'MY LINK ',
picture: 'some pic',
caption: 'Reference Documentation',
description: 'you solved the puzzle in' + this.Moves + 'turns', },
The app with the id is published on the page if that helps.

The Share Dialog is for sharing URLs only, and it takes the OG data from that URL. Earlier it was possible to use those parameters in your code with the Feed Dialog, but they are deprecated now: https://developers.facebook.com/docs/sharing/reference/feed-dialog
You could create a unique URL for it and include the score in the OG data of that URL, that´s the proper way as of now, afaik.

Related

Does botbuilder support Facebook Messenger's Button Template?

After reading this question, which is quite old now:
Does the Bot Framework support Facebook Messenger's Button Template? and viewing the list of available cards using Bot Framework.
Does botbuilder currently support Facebook Messenger's Button Template? I would like the solution to be channel-agnostic so no JSON would be required to manipulate in order to achieve this. I've tried using the hero card with no title and no image but the result is not aesthetically pleasant and the normal text stays in bold.
This is the code which renders de card:
const attachment = CardFactory.heroCard(
"",
"BotFramework Hero Card",
CardFactory.images([]),
CardFactory.actions([
{
type: "openUrl",
title: "Get started",
value: "https://learn.microsoft.com/en-us/azure/bot-service/"
},
{
type: "openUrl",
title: "Get started2",
value: "https://learn.microsoft.com/en-us/azure/bot-service/"
}
])
);
return MessageFactory.attachment(attachment);
Tried also with the ThumbnailCard but shows the same result...
If you send a hero card through the Facebook connector then it will automatically be converted to a button template if the card has only buttons and no text or images, and it will be converted to a generic template otherwise. If you want to send a customized template of your choice, you can use Bot Framework channel data. It might look something like this:
reply = {
'type': ActivityTypes.Message,
'channelData': {
'attachment': {
'type': 'template',
'payload': {
'template_type': 'button',
'text': 'Button Template',
'buttons': buttons
}
}
}
};
Note that while the answer to your question is yes, you may still be unsatisfied. You only asked for a way to use the button template instead of the generic template but your reasoning was that you want it to look better. The problem there is that the look will depend on which Messenger client you're using, and in some clients this button template will look no different from a generic template. If you try out the button template and you're still unsatisfied then you may have to do some experimenting. I think the fastest way to test this would be to send messages as your bot in an HTTP application like Postman using the Bot Framework REST API.

How to sent a website url as link to multiple Facebook Friends?

I am setting up a website. I want users to invite Facebook friends to look at the page the users can make on my website. So i'm trying to get it done. But i think the FB Api is not set up to do what i want to do. I think it is to prevent from spamming, but i really like to know if it can be done or not.
This is what i have so far. Users can login with FB and i present a decent list of FB friends.
Each friend has a checkbox. When a user submits the form, i collect all the checked friends id's:
var sendUIDs = '';
var mfsForm = document.getElementById('mfsForm');
for (var i = 0; i < mfsForm.friends.length; i++) {
if (mfsForm.friends[i].checked) {
sendUIDs += mfsForm.friends[i].value + ',';
}
}
While i was trying, i came up with this "sollution" for sending all the friends the same invite:
FB.ui({
method: 'apprequests',
to: sendUIDs,
message: "Hey come on look at my site",
data: "mywebsite.com/userlink"
});
Looking great I thought. Exactly what i wanted... i thought.
Unfortunately this is only used for games? First of all i could not find the invite. It was there, but it seems to disappear. Then i found out it was in the App/Games/Activity tab.
I managed to get the notification in the "notification" tab by adding a Canvas to my FB App. Almost there i thought. Well, not exactly... I want the friends to visit my page by the given data link and not some weird ?number.
So i gave up this path and tried the other way and came up with this:
for (var i = 0; i < mfsForm.friends.length; i++) {
if (mfsForm.friends[i].checked) {
var uid = mfsForm.friends[i].value;
FB.ui({
to : uid,
method: 'send',
name: 'Visit my page',
link: 'mywebsite.com/userlink'
});
}
}
This works more or less, but produces a popup for every friend with an empty message box. Not very friendly and, well... stupid :)
I also tried the former setup, but instead of "apprequests" i used this:
FB.ui({
method: 'send',
to: sendUIDs,
message: "Hey come on look at my site",
data: "mywebsite.com/userlink"
});
where i tried this for the sendUIDs: [1, 2, ...] and just 1, 2, ...
No luck, because FB only processed one name.
I would think there must be a way to get the job done, but for now i am very confused how to proceed. I would think FB could make things a bit more easy?
The Send and Share Dialogs are built for this (sharing a Website URL on a wall or send it to friends in a PM), just let him choose the friends in the popup. That way, you don´t even need to authorize the user, and you can´t get ALL friends anyway (only those who authorized the app too).
About the message parameter: You are not allowed to prefill the message, it has to be 100% user generated. See the Platform Policy: https://developers.facebook.com/policy
2.3 Ensure that all content in the user message parameter is entered by the user. Don’t pre-fill. This includes posts, messages, comments,
and captions.
The FB.ui Dialogs ignore the message parameter anyway.

Facebook - FB.UI feed and share dialog

I have some trouble with the Facebook FB.UI - Feed and Sare dialog.
I need to send the page of the website to a friend, im using the FB.UI Javascript API. According to the facebook documentation they said you have to use the "from and to" parameter. But when i use the "from and to" parameters it doesn't work. When i delete these parameters it works fine, but i cant post to a friends wall for sure.
I've been looking for a while, and have try'd the following steps:
Does the user have enabled the right settings to post on his timeline (check)
Does the user have liked the facebook page (check)
Am i logged in (check)
This is the link to the documentation: Feed and Share Dialogs
This is my code:
PS: I get the alert what is saying: "Post was published" but it doesn't show up on facebook.
function share()
{
FB.ui({
method: 'feed',
name: 'The name',
link: 'The URL',
from: '100001738814056',
to: '100003105898115',
caption: 'An example caption',
}, function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
}
edit: I've got some more information about my problem, and i guess i found the problem..
If you take a look at this image you'll see a row with: "Feed" and one with "?api_key=". If im taking a look at the URL of feed i guess it misses the get api key, not sure if iam correct
The image link
We'll after a day of searching.. i know the solution.
If you create an app in Facebook, the mode of the app is " in sandbox mode ", when you turn the sandbox mode off you can post to facebook while tagging a friend!
So my problem is solved.

Facebook js api: share a post to a friend's wall

i really hope, someone can point me into the right direction. I am ordered to write a drawing game for facebook. The concept is, the one, applying for a win, references a friend for the prize (the player won't win anything, just his friend).
The customer want's a Post on both Walls/Timelines. AFAIK it's not possible to post on the friend's wall. Right now i am as far, that the App posts on the wall, of whom is playing.
Is it possible to share this Post to his friend without any Dialog or represent to the friend, that he is applied for a prize?
The customer wants that this doesn't use any share/feed dialog.
Thanks in advance
After the second day of digging in i came to a solution. As the Open Graph Api mentions, the keyword is tagging BUT, the META tags mentioned in the documentation didn't work for me in any way.
I came up to use an Page ID for the place field and used the friends ID as value for the tags field. Once the friend is tagged with the post, he will see the same post on his own timeline.
Here's a snippet:
facebook.api('/me/feed', 'POST', {
'message' : userdata.name + ' hat für ' + frienddata.name + ' einen ' + $('span.buggyname').html() + '...',
'picture' : 'some picture URL',
'link' : 'URL to see game result',
'name' : 'our awesome game',
'place' : 'pageid of customer',
'tags' : frienddata.id
}, function(response){
console.log(response);
});

Send a message to a friend, I wonder Javascript API

I am a developer from the Republic of Korea.
I am currently making Facebook and Twitter-based websites.
I want to use a JavaScript API that can send message to friends,
So I consulted the iframe Javascript API methods or using Facebook page looked as sending.
I wonder,
I use to send messages to friends as a Javascript API that provides a?
I do not know English well. So I used Google translator.
Please understand.
(Edited, fixed some grammar and rewording)
FB.api (path, "post", {
message: msg,
caption: "caption caption",
link: "http://www.naver.com",
description: "Description Description",
picture: "http://sstatic.naver.net/search/img3/h1_naver.gif",
tag: "Tag",
name: "name names",
access_token: accessToken
}, Function (response) {
if (! response | | response.error){
alert ("error");
}
else{
alert (response.id);
}
})
You want to send a message to a friend on Facebook, or post to the Facebook wall for all to see? I am going to assume sending a message to a friend on Facebook.
Manual
If you want to send a message to friends on Facebook using the JS SDK, follow these instructions: https://developers.facebook.com/docs/reference/dialogs/send/
This isn't automatic and will still show a dialog box for the user to confirm.
Automatic
If you wanted to do it in the background via the Graph API, you can't. Here is a link explaining it in further detail why you can't and other options you have: https://stackoverflow.com/a/4061298/540339

Categories