Find amount of notifications through the facebook api - facebook-graph-api

How would I be able to find out how many notifications I have through the facebook php api? For example, how many unread messages + global notifications + unanswered friend requests.

summary.unseen_count in /me/notifications
summary.unread_count and summary.total_count in /me/friendrequests
I expect a similar summary.<something>_count field to exist for messages, but haven't tested.

Prompt the user for manage_notifications permission and call /me/notifications and count them up. You could also run a FQL query on the notifications table but FQL doesn't support count so you would have to loop through all the records to sum them up as well.

Related

Multiple Sessions in AWS Lex

Is it possible to have multiple sessions running parallel to a single AWS Lex bot? I have a chatbot application with two intents: Order Pizza and Book Ticket in a single bot. A user gives the first query to book a ticket and simultaneously different user queries about ordering pizza from a different machine. How to track both the requests as separate sessions in Lex.
Thanks in advance.
in this aws docs
you can see "userId" attributes in Input Event Format
userId allocated by session(what you mean).
I heard it can be slack id or user account property (maybe)
so we can track by this userId
parallel processing is will supported by aws.
you just code lambda or something to hook function with userId.

"Average Daily Active Users" for Facebook API Limits

I've suddenly started running into API limits. I've been restricting my API calls to: number of users * 200, but I'm getting error #4 about once per day.
This calculation was based on the docs from end of 2015 that said number of users your app had yesterday, plus new logins today.
But it looks like that has changed to:
The number of users your app has is the average daily active users of your app, plus today's new logins
Can someone explain to me what "average daily active users" is? And is there a way I can get access to this number?
Some information on what I'm doing:
My app fetches pages and posts from pages. To do this, I hit the Facebook API to get user's liked pages. Then each hour, I fetch posts from pages the system knows about.
I do the following:
Batch requests (50 per batch)
I'm only fetching posts since the last fetch (using since, until and limit params. 90% of the requests return 0 posts)
I'm only fetching posts from pages my users like
I'm using my app token for these requests
I limit the number of calls per hour to users * 200
Batch Requests don´t reduce API limits, they are only faster, that´s all. That being said: You wrote that you are using an "App Token" for the requests - you should use a "User Token" instead. It´s still a LOT of calls though, the only thing you can do in addition is to reduce the amount of API calls.
I found this endpoint in the documentation: https://developers.facebook.com/docs/graph-api/reference/application/
I tested this via
https://graph.facebook.com/v2.10/<my_app_id>?access_token=<my_access_token>&fields=daily_active_users
And it returned
{
"daily_active_users": "152",
"id": "<my_app_id>"
}
It is not average daily active users though

Convert FQL statement to Graph

With FQL being phased out I need to achieve the same functions via the Graph API.
My application checks for new posts, comments and replies on a company page every X seconds.
I use 1 FQL to get new comments and replies by doing
SELECT post_id,time,fromid, text,id from comment WHERE time > (lastcheck) and post_id in (select post_id from stream where source_id = (PageID) limit 1000) order by time desc
This appears to work well ,I can add a comment to a 5 month old post and it picks it up.
How can the same be achieved with the Graph API?
I think that if what you have works then you do not need to change it. Contrary to what Facebook wants you to do (use the graph api), not every query can be translated to it. FQL is alive and kicking and used heavily both in the Facebook website and mobile apps.

How to get user count by status of facebook events (attending, Invited, etc..)

Is there any way to get the user count by status of facebook events? Facebook does this on the event page (the left columng with each status has a count next to it), but could not find any documentation on how to do the same. It needs to work for small or large events. For small events, I can easily get the list of users and do a quick count. But for events with over 1000 users, the previous method is too slow and not acceptable.
I don't think there's a better way than count every list of users as explained below.
You can which users are 'attending' an event by issuing an HTTP GET to /EVENT_ID/attending
You can which users have replied 'maybe' to an event by issuing an HTTP GET to /EVENT_ID/maybe
You can which users are declined an event (i.e. responded 'no') by issuing an HTTP GET to /EVENT_ID/declined
You can which users have not replied to an event by issuing an HTTP GET to /EVENT_ID/noreply
Taken from https://developers.facebook.com/docs/reference/api/event/
UPDATE 28-Jun:
As of today, Facebook added new fields to the Event FQL table that allows you to do exactly what you want.
From the developers blog:
We've added the following fields to the event FQL table to make it
easier to get the counts of users RSVP-ed to an event:
all_members_count
attending_count
unsure_count
declined_count
not_replied_count
They're pretty much self-explanatory.

How to send customerId (x_cust_id) to authorize.net ARB?

I know, this is [normally] an RTFM question, except, well, we're talking about Authorize.net so the FM is hardly R-able.
I noticed when looking at the all the fields that get sent during the Silent Post, Authorize.net returns an item called "x_cust_id". It is not addressed in their sample code, and I can't find out where in the XML document that field would get posted. I'd like to use it!
So, how exactly do I add "customer Id" when I create a new ARB subscription?
Furthermore, is there any documentation that actually shows all the information I can send to ARB? I don't even know what my options are!
Silent Post != ARB. They are two different things. Silent Post is triggered whenever a transaction is processed by Authorize.Net. They send the results of each transaction to a script on your server notifying it of the results of the transaction. This allows you to manage subscriptions that fail programatically. It is very similar to Paypal's IPN. x_cust_id will be populated from the <customer/><id/> field in the ARBCreateSubscriptionRequest API call.
FYI, this is explained on pages 20 and 21 of the ARB guide.