how to match graph and messenger messages? - facebook

I am receiving messages via graph and messenger API in order to improve user experience. Private messages are duplicated on these 2 API and I need to match duplicates.
Unfortunately user IDs and messages IDs are different between these 2 APIs. I know that I can use ID matching API to convert user IDs from one API to the other. But is there an official way to convert a messenger message ID into a graph message ID ?
Here is an example:
messenger ID = mid.$cAALDdi6ZFO1jb_oJHVdOrTAZvk45
graph ID = m_mid.$cAALDdi6ZFO1jb_oJHVdOrTAZvk45
Obviously I can get rid the 'm_' at the beginning of graph ID to convert it into a messenger ID. Will this work for every message ? If yes please point me to the corresponding facebook doc !

Related

Start conversation without user interaction in Facebook Messenger

Is it possible to send a message to a user without the user interacting with the bot first?
I'm using the following guide to retrieve psids from users that have already connected their profile to an app that I own.
https://developers.facebook.com/docs/messenger-platform/connecting-accounts.
For users that have at least one interaction with a page that I also own, I'm able to get their id. For all other users the endpoint returns an empty array.
Im aware of customer matching but is that the only way to achieve this?
You can't send a message by bot before the user initializes the conversation.
Facebook Messanger Bot permits a standard messages, with a 24-hour interval
to reply to a message initiated by a user. In Some specific cases, Facebook permits to send a message after this time.
A message are triggerd when the user either sends a message to a company or clicks a call button for action in Messenger, or when the user requests a message from a company through a plugin, such as send to Messenger.
Check out the policies here : https://developers.facebook.com/docs/messenger-platform/policy-overview
You are correct, customer matching is your only option for this.
Just learned this today, if you have a user's phone number, you can message them unprompted. You also need the pages_messaging_phone_number permission, which you can only get by paying the $99 customer matching fee.
Check the docs on sending to phone numbers here. Customer matching docs here

From Gmail to Facebook

Is there any way to post messages received in an email, directly as a Facebook post?
If yes, how can I do that?
I want to automate a page in Fb to spend less time there
Yes, one way of doing it would be to create a service or scheduled task which periodically does the following:
Use gmail API to get all unread messages
Each message will have an ID and you are able to check whether it has been read
Use the IDs to retrieve the message bodies
Use Facebook API to post the body data to the page
You can use Ballerina to create a stand-alone program or a service that you can invoke when it's needed. Use the facebook connector to get a list of comments and posts from your facebook page, create a payload string and send it to a destination email using the gmail connector. Look at the samples shipped with the distribution to get a head start.

Facebook Graph API - Attending list length != attending_count

Graph API - Event: https://developers.facebook.com/docs/graph-api/reference/event/
When I get the attending_count of an event the API returns the correct number of people attending an event.
When I request the list of people going via attending (Edge) I'm getting less people.
The problem is that the attending (Edge) request does not only return names, but also the user id of each user. The ones who have their ID set to Friends-only in their privacy settings are not being listed.
I don't even need the ID, only the names. In my browser I can easily read ALL names, even of the people who set their ID to privat.
So is there away to get the names without the ID?
Tried to set the parameter fields to first_name only, so no ID, but still, it's giving me first_name AND ID of each attending user.
Some people may have disabled the Facebook Platform, so they don´t show up in the list - but they still add to the count.

Possibility on implementating sending Direct message using Twitter API

I would like to know how to send Multiple Direct message on Twitter. In my app using twitter api, i am able to send Direct message to one( Using DM Syntax ).
Currently i can see some tools like MultiDM website allows to send multiple Direct messages at a time.
So is that possible from iPhone's twitter api?
Also i wonder how the MultiDM website works as such
Pls let me know
In twitter API there is only 1 method of sending a DM: https://dev.twitter.com/docs/api/1/post/direct_messages/new
If you need to send multiple DM's - just call this method multiple times (with different recipient)
Yes you cant send DM to more than one user in a single call of the API.
If you want to send DM to multiple users, just make an array of all users id or screen name and in a loop send direct messages to All through the below API...
https://dev.twitter.com/docs/api/1/post/direct_messages/new

Facebook Graph API Data Incorrect

Small problem here. I have an event created on Facebook and am using the Graph API to get the number of attendees.
I get the list of attendees with PHP from https://graph.facebook.com/EVENTID/attending?access_token=TOKENHERE and it returns a list of names.
However, the number of attendees is about 6 people lower than what is shown on the Facebook event page. Why would these numbers not match? Is there something in particular I'm supposed to do in the code to get the entire list?
As answered in the comments:
This discrepancy is probably down to a number of the attendees having opted out of Facebook Platform, which means their data isn't passed to apps via the API. Can't be 100% sure without the Event ID, but its a likely reason. – Simon Cross
From the Graph API, the people who have not joined the event will not show up under /{eventid}/attending, you need to add in the users who are returned in /{eventid}/not_replied. The not_replied set seems to be a special set in the GraphAPI.. and if you look at the docs, there is a mention of only people who have joined the event.