I have a web-chat application with group-chat. Now I can invite other users to my room, I can listen to invitations and I can decline an invitation, but for some reason, when a user declines my invitation, it doesn't trigger my onDecline method. Here's the part where I add the handler:
connection.addHandler(onDecline, Strophe.NS.MUC_USER);
//(Strophe.NS.MUC_USER = http://jabber.org/protocol/muc#user)
I get the following XML when the user declines:
<body xmlns="http://jabber.org/protocol/httpbind">
<message xmlns="jabber:client" from="qvxuceluy#conference.127.0.0.1" to="hampel.elod_reea.net#127.0.0.1">
<x xmlns="http://jabber.org/protocol/muc#user">
<decline from="40756382284#127.0.0.1">
<reason>Busy!</reason>
</decline>
</x>
</message>
</body>
Your message handler might be intercepting it. Make sure your message handler has "groupchat" or "chat" for the type (onMessage, null, 'message', 'chat'). Or you can handle it through your message handler.
Related
I am sending apprequest to send "Gift" to friends.
Code which i am using to send gift is as below :
FB.AppRequest (Send_Gift_Message, OGActionType.SEND, GIFT_10_COINS, toFriends, null, "Send Gift", delegate(IAppRequestResult result) {
});
This is sending gift request perfectly but i just want to change message which is shown while sending gift.
I am attaching image which shows message :
I want to change "sent you a coin:". I want to use "sent you coins:".
Is it possible to change ?
If it is possible then plaese guide me steps.
Thanks.
I am working with the Facebook Javascript SDK and I am trying to set up a rewards system for sending invites to Friends. Basically, I want to give the user points for simply sending invites to their friends using the friend invite dialog provided by the Facebook Javascript SDK. That said, I set everything up based on the Friend Smash tutorial on the FB developers website and I am creating a custom, multi-friend selector to send invites. The invite dialog comes up properly and the invite sends correctly.
The Javascript that sends the invite looks like this:
function sendRequest() {
// Get the list of selected friends
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 + ',';
}
}
// Use FB.ui to send the Request(s)
FB.ui({method: 'apprequests',
to: sendUIDs,
title: 'Help me get some points!',
message: 'Help me get some points by coming over to XXX and registering to play!',
}, callback);
}
However the request's response object looks like this when sending to one friend:
{request: "412752342228182", to: Array[1]}
And it looks like this when inviting two friends:
{request: "414967121961627", to: Array[2]}
The object contains the "request" field which is the unique request ID for the invite, as expected. The Facebook documentation states I am supposed to get an array of user IDs of the recipients in the response object's "to" field but that strange Array[X] is there instead. Is this the correct response? Am I missing something?
Any help on this is appreciated. Thanks in advance for your time.
Nevermind, I figured it out. The Array[X] is more of a placeholder for the actual array so if you parse to[0] or to[1], you get the actual userids for those that you invited.
We've been running the Facebook Chat API on our app for months, but since recently we started to get 1 out of 5 messages that don't seem to be sent anymore.
For sending we use this:
sender_chat_id = "-#{uid}#chat.facebook.com"
client = Jabber::Client.new(Jabber::JID.new(sender_chat_id))
client.connect
client.auth_sasl(Jabber::SASL::XFacebookPlatform.new(client,
app_id,
access_token,
app_secret]
), nil)
# Send messages
client.send(jabber_message)
# Close chat client
client.close
and it seems to work. then we check if the message is sent with:
Fql.execute({
"query1" => "SELECT body FROM message WHERE thread_id IN (SELECT thread_id, recipients FROM thread WHERE folder_id = 1 AND #{receiver_uid} IN recipients ORDER BY updated_time DESC) ORDER BY created_time DESC"
}, {
access_token: access_token
})
And unfortunately sometimes the message just won't appear in the outbox.
EDIT:
The problem seems to come from messages sent to people that don't have a thread with the sender containing previous messages.
In those cases, the message sent by the Facebook chat API is not delivered.
However when if the sender sends a message to the receiver (or vice versa) "manually", the thread is opened and all the messages sent before by the API appear...
For sending the apprequest with custom message, I was using a js api, undocumented parameter new_style_message set to be true, but now it seems to stop working.
This is how I was sending the request:
FB.ui({method: 'apprequests',
message: 'notification message',
title: 'tile of request',
data: '$gid',
to: user_ids,
new_style_message:true
}, requestCallback);
Does anybody have any workarounds? Please help.
Update: The request is being sent properly, it's just not showing up with the custom message to whom I sent the request. I want to know is there a way I can send it with a custom message?
I use default facebook dialog to ask for request
<script type="text/javascript">
function sendRequestToRandomFriends() {
FB.ui({method: 'apprequests',
message: '<?= na ('request text') ?>',
to: '<? $to = '';
foreach ($Rfriends as $c) {
if (isset($c['uid'])) $to .= $c['uid'] . ',';
}
if (!empty($to)) echo substr($to, 0, -1); ?>'
}, requestCallback);
}
But I saw many self created dialog windows , which ask to send requests.
How they sends requests when user press the button ?
I found your answer. It is buried deep down in the documentation. To send a user request without the FB.ui dialog you can use the grpah api's create user request to send.
Create
You can post a apprequest for a user by issuing an HTTP POST request
to /USER_ID/apprequests with the app access_token.
Note: POSTing to the Graph API endpoint of /USER_ID/apprequests is
considered an App to User Request. App-Generated Requests do not
receive notifications and get limited distribution in comparison to
User to User Requests sent with the Request Dialog