Facebook Request Dialog for single person - javascript

I am making a simple turn based board game on facebook. I plan to make a multiplayer mode where two player can play together like a duel mode. To do that, a person can send an app request to another person using facebook request dialog. But the user can select more that one person in that dialog. How do I make it send the request to only one person?
I could send to only one person using the graph API. But then, I need to get the target person's facebook id. I couldnt just 'prompt("Give me the user's facebook id")' for it. What the user need is a dialog where the user can select one of his friends, and return the facebook id. Is there such dialog in facebook? Or I will just need to make one.

You need to make one yourself.
Retrieve all friends through Graph API or FQL
Let the user choose one of them
Fire the Request Dialog with that specific friend's ID

i had the same question and landed here. I know that this is a old question but still people can and will find this.
So the right answer for me is:
FB.ui({method: 'apprequests',
message: 'My Great Request',
max_recipients : 1
}, requestCallback);
You can find this information at https://developers.facebook.com/docs/reference/dialogs/requests/
I hope I could help some developers
cheers.

Related

Sending message on Intercom on user's behalf

does anyone know how to send a message from intercom(https://www.intercom.com/) on user's behalf? I need to set up an event listener that opens intercom chat window and sends a message when a some button is clicked.
i am working with react version of intercom if it helps.
will be very grateful for any hints.
If you are using the Intercom chat widget, you can pre-populate a custom message in the widget on the user's behalf like so
const myCustomMessage = 'Hi there!'
window.Intercom('showNewMessage', myCustomMessage)
Of course, the user still has to actually send the message. This might not be exactly what you wanted but it's an alternative in case you want to fully automate everything except the decision to send the message (which is the right UX in a lot of situations).
Documentation is here.
for those who are in the same trouble:
https://developers.intercom.com/reference#user-or-contact-initiated-conversation
For sending messages on the user's behalf, you may check this out https://developers.intercom.com/intercom-api-reference/reference/create-a-conversation
You may need the user's user_id or id from the reference above to create a conversation. For those who are using MobileSDK or intercom_flutter, the id is not provided within the package or SDK. I found a workaround by using this Search for contacts API to get the id.

SignalR Content Specific Notifications

I am using SignalR for notifications in my web site but i couldn't find a way to send notifications according to the page/content.
Let me explain in details.
Assume that, there is a page for showing a record from database (for example a blog post).
So there is only one page for showing posts as it should be.
And every post has a like counter which i want to update via signalr notifications, if another user clicks like button. Until here, it is very easy to accomplish.
This page contains a javascript code block like below
var notify = $.connection.notificationHub;
notify.client.updatePostLikeCount = function (likeCount) {
$("#likeCount").text(likeCount);
};
And this function triggered from server-side like below (it is in another class instead of Hub class)
var context = GlobalHost.ConnectionManager.GetHubContext<NotificationHub>();
context.Clients.User(user.Id).updatePostLikeCount(likeCount);
But a user might open more than one post; so if a notification is sent from server-side all opened tabs receive this notification and update its counter.
I looked for .Caller method but it is not available in IHubContext interface which GetHubContext() returns and couldn't find another way.
To summarize, i want to send notifications to users who had opened the post which user liked.
EDIT: After sending question i got an idea. Continue sending notification as being and filtering according to the content at client side. It is not very good but i think it will work with charms.

how to send message in friends message folder/inbox in facebook?

I want to send message to facebook friend's inbox/message folder from my application using either javascript or php sdk How can I do that?
Before, this we used
FB.api('me/feed', 'post' ......
method to post in friends wall from my application but now that method is removed from FEB 2013, I also tried sending mail at
FACEBOOK_FRIENDS_USERNAME#facebook.com
but this method also didn't work all the time some time message was going to others folder in messages but not all the time, Can anyone tell me why this is happening? I rechecked my code, the username was correct to where I was sending the mail.
I have also tried
FB.ui({method : 'send', .....
method but it opens one dialog for sending message and then we have to select multiple friends I don't want that, I want to send message to user's facebook friends directly from my application.
If there is some other way to implement this please help me?
You can't send message to a User's friend you can only read User's messages throgh the application ,check this link.
But if you still need the functionality to either post on the friend's wall or send message to a User's friend you can use Facebook JavaScript SDK's share.stream method
<script>
var share = {
method: 'stream.share',
u: 'http://www.fbrell.com/'
};
FB.ui(share, Log.info.bind('stream.share callback'));
</script>
or you can utilize Send Dialog

Is it possible with facebook-php-sdk to post to a user's wall without leaving "via" in the status update?

[My Goal:]
I want to provide users with a facebook login button on my site with a FORM for them to fill out
that will post status updates to their wall from my site so they don't have to leave my site to goto facebook.
[The Situation:]
I'm using the facebook php Software development kit found here:
https://github.com/facebook/facebook-php-sdk
The examples/with_js_sdk.php demo script works for displaying the user's account information.
I have edited it so it posts a new status update to the user's wall with "testing this api' by making the following changes to the script:
$user_profile = $facebook->api('/me');
$facebook->api(
array(
'method' => 'users.setStatus'
, 'status' => 'testing this api'
, 'uid' => $user_profile['id']
)
);
The login button reads:
[My Issue:]
The issue I have with the above is that, unlike a user actually posting to their wall manually, posting via the api includes a link to the api that posted it.
Thus their post on facebook would look like:
is testing this api
4 seconds ago via MyAPINameWithALinkToThePageIDontWantPeopleToKnow
I don't want the API to include the "via" part in the user's status update on their wall.
[My Question:]
Is what I want, as far as leaving out the "via" part in the user's post, possible through the facebook api?
[What I've Tried:]
I've tried looking through the facebook api documentation.
I've tried googling this question and found similar questions:
https://stackoverflow.com/questions/12756777/remove-app-name-in-app-post-feed-using-facebook-javascript-sdk
http://www.vbforums.com/showthread.php?658541-Facebook-omit-quot-via-app-name-quot-from-Wall-posts
Seems to be hopeless...
then I found that this isn't possible via feed dialog. So I used Open Graph actions to accomplish this.
Use this for making your app smart :)

make turn on/off or deauthorized user from my app, and list action of user from app

I submitting an app to Facebook with open graph news read type by javascript.
All done so well with flow from user asking for authorized my app, and show the button help user can public the article then they can remove if they want to.
Today I got the request from Facebook need to change my app:
requirements
(https://developers.facebook.com/docs/opengraph/actions/builtin/#read).
Please make sure your users can (1) Turn sharing on/off globally on
each page an article appears. (2) Remove articles they shared within
your app on each page an article appears. (3) Only generate read
actions when you're sure someone is interested in reading the article
- only publish after 10 seconds.
The third request is easy just use timeout to show the button submit after user read article.
The seconds is so hard because I don't know how to full the array list of pass action of user doing with my app include action id and title of article they post which I can use to create "remove link" for each of them if user want to.
The fist request I did search for method of javascript to de-authorized the app from user (not revoke permission) so I can ask user to be reauthorized if they need.
Please help.
Beside I see very nice 2 sample in guild page
https://developers.facebook.com/attachment/OG_App_PublishToggle.png
https://developers.facebook.com/attachment/OG_App_DeleteActivity.png
But they din't give out the link of live site using it.
or may be that is one of Facebook markup similar "recommend box" , but how/where we can get it?
Please advices for the script or sample as Facebook dose will be help full
regards
UPDATE 1 I found the way to reauthorized all app or revoke one permission.
here the function:
var permsNeededPub = "publish_stream";
///notice that if permission is "publish_actions" revoke function not work
function xlfb_revokePerm() {
FB.api("/me/permissions", "delete",{permission:permsNeededPub}, function(response){
console.log(response);
if(response){
console.log(' Remove success '+permsNeededPub);
}
});
}
function xlfb_removeApp() {
FB.api("/me/permissions", "delete", function(response){
console.log("User removed the app from acount: "+response);
});
};
The seconds is so hard because I don't know how to full the array list of pass action of user doing with my app include action id and title of article they post which I can use to create "remove link" for each of them if user want to.
Whenever a user takes an OG action on your site - save the action_instance_id you are getting back from the API call and whatever extra data you might need to your database.
The fist request I did search for method of javascript to de-authorized the app from user (not revoke permission) so I can ask user to be reauthorized if they need.
Why would you want to de-authorize the app?
All that’s required here is to have a global on/off switch for all sharing activity – so if the user sets it to off, then you just don’t publish any actions for him as long as he leaves this setting set to off.

Categories