Open ezaca opened 6 years ago
Cool stuff! So you'll need to really replicate the request the browser makes, down to all the headers, all the query parameters and all data you send as body (when it's a POST). You said you cleared the form, make sure you didn't remove anything, because those might be used (well you never know). You'll also need to make the correct type of request GET/POST. We automatically attach the cookies if you use the defaultFunc. There might be other cookies we are not sending, check the request the browser makes!
Finally, maybe the nodejs instance tells FB that it's a different browser than yours, which might influence how it responds to your request. Try matching the browser versions also by tweaking the headers in the post
function function in utils.js
.
"I get an incomplete answer" sometimes facebook uses two requests for some things. eg. one requests gives you some list of things, with basic info, and another request (where you tell them what you want) gives you full info
Thank you both! It's working now 😃 . It is simple and get only the last notifications (no "cursor" for now), and it is not for Messenger, then I don't know if they will want to include the function in the package in this state, but I think I will format the code and try to open a pull request anyway.
Hi, everyone!
I was playing around with this great library, and I was trying to list notifications of a Facebook profile (not Messenger).
First, i don't know if this library is intended for that, but it seems to work and I would love to use it for a personal application that informs me about notifications in more than one account in same browser (shhh, don't let they know).
What did I do? Step-by-step
module/src/getNotificationList.js
and copy fromgetThreadList.js
;index.js
;callback
;defaultFuncs.post
with our form (I cleared the form and added only the "data" and "__a" field, see below for details);listen
function call by our method;payload
as the getThreadList do, but get the whole answer and look for ajsmods
field.What is wrong? I got the answer, it's a JSON, it's OK, but it's pretty different from what I get in the browser! In Firefox I get all the fields with the notifications, but in Node I get an incomplete answer. The field with the notifications is missing.
What is the request that works in browsers? With a logged account, access this link. The link is composed by:
facebook.com
;ajax/pagelet/generic.php/WebNotificationsPayloadPagelet
data
JSON with{businessUserID, length, clientRequestID}
;__a
field.The fields are OK, but you must send the cookies too. Because of that, I tried to use the
post
function matching what getThreadList did. In Firefox, for example, I can find (Ctrl+F) for the text of my last notifications, but they do not appear on Node.So what I want is to receive the same JSON as I received in Firefox, so I can access
response.jsmods.require[0][3][2].nodes
array (this index will be resolved programatically, not hard-coded) and get the information about the last notifications in the profile.Any hint of what is going on? Did the link worked to you?