Send a Message or Notification to the friend in facebook - php

I need to send a message or a notification about an event or something else to my friend from my facebook application for website. The rest api is no longer in use ....So is there any other ways...Sample codes???
Thanks in advance....

You can't as yet send notifications via the new API.
While we currently don't allow
applications to send messages through
this API, we're always thinking about
new functionality to offer through
Facebook Platform.
Source: http://developers.facebook.com/blog/post/291

"Sample codes" and documentation, straight from the horse's mouth: http://developers.facebook.com/docs/api
See especially the sections labelled "Reading" and "Publishing"

Related

Bot replying to app_mention event in the wrong channel

I'm trying to work with the slack Event Subscription app_mention, but I'm having some issues.
My backend is PHP, and I'm using this class.
Basically, what's happening is, if I have my bot user in multiple channels and someone mentions the bot, it will only reply in a single channel.
For example;
I have the bot user in 2 channels
bot-testing
development
If I # mention the bot in the development channel, it will send it's reply in the bot-testing channel.
My code used to send the message:
$client->to('#' . $event['channel'])->send("Hi. I'm currently under development.");
and my $event variable looks like this:
{"type":"app_mention","text":"<#UFT4EG0Q7> test","user":"UAKTRFH41","ts":"1548783398.055200","channel":"GAMED4PK5","event_ts":"1548783398.055200"}
but decoded obviously.
Why is my bot not replying in the correct channel?
So based on my reading of the PHP client you're using, that's designed for use with Incoming Webhooks.
Incoming Webhooks have a 1:1 relationship with a conversation/channel, so you can't define the destination for your message in the payload you send to the API.
If you want to do that, you could try using one of the other PHP SDKs built by the community.

Facebook. Is it possible to send private messages?

I know that it may be stupid to post this question again because there are a lot of simmilar questions. But they are all dated 2010-2012 years and the info may be updated. Especially with new version of the facebook API V2.0 from April 30th, 2014.
I've made some digging on the possible options and found Chat API and interesting post related to it: http://nishgtm.com/2013/11/facebook-message-api-php/
But I couldn't make it work.
Also there some info on new Message Dialog thing on the FB docs but there are only iOS and Android examples.
I'm building a web application and a mobile application. And I wonder, is it possible to send private messages on the behalf of the fb application, not fb user.
It's not possible to send messages on behalf of the application.
To let people that use your app send to their friends, use:
iOS: https://developers.facebook.com/docs/ios/message-dialog/
Android: https://developers.facebook.com/docs/android/message-dialog/
desktop web: https://developers.facebook.com/docs/sharing/reference/send-dialog
mobile web: unfortunately, this isn't supported yet
It's 2017 and I found something interesting. We can send private messages on mobile now, but it's buried. Facebook decided to allow sending private messages to the Share Dialog where the user has to click the dropdown and select "Share in a private message". This works on all platforms and I attached a screenshot below. I hope this helps someone in the future until Facebook decides to change things again.
Read about
https://developers.facebook.com/docs/games/notifications
this may be what you need

App request/Invite through Facebook API using PHP

I'm building an app and the client wants the following logic:
User logs in to the app.
User selects a Friend.
User selects a gift that the User will send to his Friend.
User writes a message to his Friend.
Friend receives a SECRET notification about the gift.
With "SECRET" I mean that Friend will not be able to see WHO is the User that sent the gift.
So the concrete question is how to send a notification to the FRIEND without a clue about the USER that sent it? I think is not possible but I want to be sure and check with the experts.
And if it's not possible, what do you recommend to accomplish something like this? Should I use the app request dialog and hope that the Friend will see it? Is there any other FB API tool I can use?
I really appreciate your help.
What you're trying to achieve is not possible with FB's API. As explained already by #CBroe.
You can send a request notification if the user uses your app. However, You can do one thing but that won't be completely anonymous.
You can send the friend a notification from the user and make it just an invite to try the application and after the friend uses your app (authenticates), your app can then send a notification and say someone left a SECRET message for them. This could be after few hours or instant, Whatever you/your client prefers. However as i said, this won't be completely anonymous nor it's hard to guess who left the message unless the friend isn't smart enough to know who that could be.
With the beta Notification API something similar would be possible, but only if the receiver has authenticated your app: https://developers.facebook.com/docs/games/notifications/#impl

Facebook API. Notification via social plugin comments

I have a page with a comments social plugin, I would like to know if it's possible to notify users who have already commented on the form.
I can subscribe to the comment.create function, but how do I send notifications?
I know actual notifications are now impossible, but is there another way? (Sending a message from the user perhaps?). With the format of my page, they will want to know when someone has posted.
I haven't tried that, it's just an idea.
https://developers.facebook.com/docs/reference/plugins/comments/ - look at the section describing way of getting comments via Graph API.
E-mail way:
You can ask each user who logs into your site to allow you to get his e-mail address. Then, you would subscribe to this event, list users who commented an article and send them an e-mail.
Message way:
You need a Facebook page for your site. Then you would receive a token for this page (manage_pages permission), get publish_stream permission in behalf of this page and publish message to streams of users who commented.
It may be also possible to send user a message on behalf of a page using Graph API, however I haven't seen anything like that in docs
This is not allowed by facebook, the attempt will result something like this:
{
"error": {
"message": "An unknown error has occurred.",
"type": "OAuthException"
}
}
This is because the social plugins do not "live" inside facebook, they are being distributed to 3rd party sites, and to prevent bad content posted from bots/apps to display in 3rd party websites, facebook has disabled this option.
Search for WordPress Plugin called Ultimate Facebook Comments Email Notify. I hope it will solve your problem...and you can also take some idea from his script which he is using in the plugin....hope this helps :)

Chat Invitation using XMPPHP

Is it possible to send chat invitations using XMPPHP?
I have successfully setup the messaging system from a CMS, but I am looking for a way to send chat request before the first message is sent.
Is it possible to do that in XMPPHP? I am asking this because I could not find any proper documentation for the class. Thank you for any input.
you can use below for send chat invitation.
$conn->subscribe('$jid');
by
$conn->unsubscribe('$jid');
you can remove jid from your contact list
Typically in XMPP, we don't send a request first, we just send the first message. If you MUST have this feature, you'll want the protocol from XEP-155 (Stanza Session Negotiation). You'll likely need to implement this protocol yourself, and also deal with the case where the client on the other side doesn't implement the protocol... mostly because NOBODY has implemented this. :)

Categories