Best way to calculate 24 hours window of Facebook Messenger - facebook-graph-api

I notice Facebook Messenger Policy stated that the Page won't be able to send the user a message after 24 hours session/window ended.
I am trying to iterate over a list of Facebook User PSIDs, and send some update to them. For those users that are outside of 24 hours window, I would not want to send any message to them.
I have researched over the Facebook Messenger Graph API and found few of the API are suitable for use to calculate.
To get the user conversation ID
https://graph.facebook.com/v16.0/<PAGE_ID>/conversations?platform=messenger&user_id=<USER_ID>
To get the user message list containing Message ID
https://graph.facebook.com/v16.0/<CONVERSATION_ID>?fields=messages
To get the user specific message
https://graph.facebook.com/v16.0/<MESSAGE_ID>?fields=from,to,message
By using this method, I am able to know when is the last message sent by the user. But there are downside to this approach because just for a single user, I have to call multiple APIs and it might reach the Facebook Messenger Rate Limit.
Does anyone here have better solution in order to check this problem?

Related

Is it possible to send and fetch Facebook messages using Graph API for v4.0 or greater?

I want to create a web application using PHP which will allow to connect Facebook accounts with my application and once they authenticated my application can fetch inbox messages of that user and can auto reply to the messages received against authenticated Facebook accounts.
Also, allow user to send messages manually from my application to Facebook inbox.
Is this possible with Graph API or any other Facebook API which will allow me to do above mentioned things.
Some people was told that this feature is no longer available after Facebook Graph API v2.4.
and once they authenticated my application can fetch inbox messages of that user and can auto reply to the messages received against authenticated Facebook accounts.
Neither of those two things is possible.
You can not read the messages of user accounts any more, and you can not reply in their name either.
The only messaging that can be handled via API, is that between a user and a page.
Assuming you refer to Page conversations, not user conversation, see /conversations and /messages docs here:
https://developers.facebook.com/docs/graph-api/reference/page/conversations/
https://developers.facebook.com/docs/graph-api/reference/v5.0/conversation/messages

Can I send message to a page using Facebook Graph API?

I saw that is possible to use Graph API to send message to a user, but I didn't find nothing about send message to a page. Is it possible?
It is not possible with the API, you can only reply to a User message as Page. Sending messages from Users to Pages is not really neccessary, Users can just use the Messenger for that. Prefilling would not be allowed anyway.

Posting to friends' wall with Graph API via 'feed' connection failing since Feb 6th 2013

My app started failing to post items on friends' feeds.
I am getting this error:
Facebook request error: The operation couldn’t be completed.
(facebookErrDomain error 10000.), details: Error Domain=facebookErrDomain Code=10000 "The operation couldn’t be completed. (facebookErrDomain error 10000.)" UserInfo=0xa26e990 {error={
code = 200;
message = "(#200) Feed story publishing to other users is disabled for this application";
type = OAuthException;
}}
I didn't change anything in the app. Maybe it is related with Facebook upgrade?
These are the permissions that I connect to Facebook with:
[appDelegate.facebook authorize:[NSArray arrayWithObjects:#"publish_stream", #"friends_birthday", nil]];
Yes, this was announced months ago and took effect on Feb 6th 2013:
Removing ability to post to friends walls via Graph API
We will remove the ability to post to a user's friends' walls via the Graph API. Specifically, posts against [user_id]/feed where [user_id] is different from the session user, or stream.publish calls where the target_id user is different from the session user, will fail. If you want to allow people to post to their friends' timelines, invoke the feed dialog. Stories that include friends via user mentions tagging or action tagging will show up on the friend’s timeline (assuming the friend approves the tag). For more info, see this blog post.
The workaround is to use the Feed Dialog which allows users to post the same content, but choose the user they want to post it to.

How to track messages from Facebook API

I´m trying to track messages sent to my Facebook friends.
For example: I sent a message to James Bond, how do I know if he read it or not?
The Facebook Graph API does not support this yet - http://developers.facebook.com/docs/reference/api/message/. I suspect this is because there is no guaranteed way to see if a message has been read or not based on how the user accesses their messages.
It would also require permission tokens to be passed in a three-legged (recipient to application, recipient to sender) verification.

How to post a message on wall of facebook using a graph api

How to post a message on the wall of facebook or add comment to the thread using a graph api.I want a url of that.
like for adding a message to wall
https://graph.facebook.com/profile_id/feed?access_token=generated token&message=hi
But it not working ,it not get added to my wall.
You need to add &method=post to your request URL. Also, you must have the `publish_stream extended permission for your application.
https://graph.facebook.com/user_id/feed?method=post&message=hi&access_token=generatedtoken.. will work
instead of profile id give the user id
Hope this will work