Skip to content

Commit

Permalink
fix conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
LarryLuTW committed May 15, 2016
2 parents 5291385 + b66502c commit 0b8d314
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
The Official Facebook Chat API uses XMPP and is deprecated as of April 30th 2015. This is a non-official API that doesn't use XMPP.
As of right now, the only way to automate the chat functionalities is to emulate the browser. This means doing the exact same GET/POST requests and tricking Facebook into thinking we're accessing the website normally. Because we're doing it this way, this API won't work with an auth token but requires the credentials of a Facebook account.


See [below](#projects) for projects using this API.

## Install
```bash
Expand Down Expand Up @@ -158,8 +158,11 @@ login({email: "FB_EMAIL", password: "FB_PASSWORD"}, function callback (err, api)
6. I'm getting some crazy weird syntax error like `SyntaxError: Unexpected token [`!!!
> Please try to update your version of node.js before submitting an issue of this nature. We like to use new language features.
Cool projects using facebook-chat-api:
<a name="projects" />
## Projects using this API
- [Kassy](https://github.com/mrkno/Kassy) - Kassy is a modular, easily extensible general purpose chat bot
- [Marc Zuckerbot](https://github.com/bsansouci/marc-zuckerbot) - Facebook chat bot
- [Marc Thuckerbot](https://github.com/bsansouci/lisp-bot) - Programmable lisp bot
- [Larry Pudding Dog Bot](https://github.com/Larry850806/facebook-chat-bot) - A facebook bot you can simply customize the response
- [MarkovsInequality](https://github.com/logicx24/MarkovsInequality) - Extensible chat bot adding useful functions to Facebook Messenger
- [AllanBot](https://github.com/AllanWang/AllanBot-Public) - Extensive module that combines the facebook api with firebase to create numerous functions; no coding experience is required to implement this.
- [Larry Pudding Dog Bot](https://github.com/Larry850806/facebook-chat-bot) - A facebook bot you can easily customize the response
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "facebook-chat-api",
"version": "1.0.8",
"version": "1.1.0",
"description": "Facebook chat API that doesn't rely on XMPP. Will NOT be deprecated April 30th 2015.",
"scripts": {
"test": "node_modules/.bin/mocha",
Expand Down
2 changes: 1 addition & 1 deletion src/getThreadHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = function(defaultFuncs, api, ctx) {
form['messages['+key+'][' + threadID + '][timestamp]'] = timestamp;
form['messages['+key+'][' + threadID + '][limit]'] = end - start;

if(ctx.globalOptions.pageId) form.request_user_id = ctx.globalOptions.pageId;
if(ctx.globalOptions.pageID) form.request_user_id = ctx.globalOptions.pageID;

defaultFuncs.post("https://www.facebook.com/ajax/mercury/thread_info.php", ctx.jar, form)
.then(utils.parseAndCheckLogin(ctx.jar, defaultFuncs))
Expand Down
8 changes: 4 additions & 4 deletions src/getThreadInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ module.exports = function(defaultFuncs, api, ctx) {
return callback(err);
}
var key = (Object.keys(userRes).length > 0) ? "user_ids" : "thread_fbids";
form['threads['+key+'][0]'] = threadID;
form['threads['+key+'][0]'] = threadID;

if(ctx.globalOptions.pageId) form.request_user_id = ctx.globalOptions.pageId;
if(ctx.globalOptions.pageId) form.request_user_id = ctx.globalOptions.pageId;

defaultFuncs.post("https://www.facebook.com/ajax/mercury/thread_info.php", ctx.jar, form)
defaultFuncs.post("https://www.facebook.com/ajax/mercury/thread_info.php", ctx.jar, form)
.then(utils.parseAndCheckLogin(ctx.jar, defaultFuncs))
.then(function(resData) {
if (resData.error) {
Expand All @@ -33,7 +33,7 @@ module.exports = function(defaultFuncs, api, ctx) {
var userData = userRes[threadID];
var info = {
participantIDs: threadData.participants.map(id => id.split(':').pop()),
name: threadData.name || userData.name,
name: threadData.name != null ? threadData.name : userData.name,
snippet: threadData.snippet,
messageCount: threadData.message_count,
emoji: threadData.custom_like_icon,
Expand Down
8 changes: 4 additions & 4 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe('Login:', function() {
assert(info.participantIDs != null && info.participantIDs.length > 0);
assert(!info.participantIDs.some(isNaN));
assert(!info.participantIDs.some(v => v.length == 0));
assert(info.name != null && info.name.length > 0);
assert(info.name != null);
assert(info.messageCount != null && !isNaN(info.messageCount));
assert(info.hasOwnProperty('emoji'));
assert(info.hasOwnProperty('nicknames'));
Expand All @@ -119,7 +119,7 @@ describe('Login:', function() {


it('should get the history of the chat (user)', function (done) {
api.getThreadHistory(userID, 0, 5, Date.now(), function(err, data) {
api.getThreadHistory(userID, 0, 5, null, function(err, data) {
checkErr(done)(err);
assert(getType(data) === "Array");
assert(data.every(function(v) {return getType(v) == "Object";}));
Expand Down Expand Up @@ -201,7 +201,7 @@ describe('Login:', function() {
});

it('should get the history of the chat (group)', function (done) {
api.getThreadHistory(groupChatID, 0, 5, Date.now(), function(err, data) {
api.getThreadHistory(groupChatID, 0, 5, null, function(err, data) {
checkErr(done)(err);
assert(getType(data) === "Array");
assert(data.every(function(v) {return getType(v) == "Object";}));
Expand Down Expand Up @@ -251,7 +251,7 @@ describe('Login:', function() {
assert(info.participantIDs != null && info.participantIDs.length > 0);
assert(!info.participantIDs.some(isNaN));
assert(!info.participantIDs.some(v => v.length == 0));
assert(info.name != null && info.name.length > 0);
assert(info.name != null);
assert(info.messageCount != null && !isNaN(info.messageCount));
assert(info.hasOwnProperty('emoji'));
assert(info.hasOwnProperty('nicknames'));
Expand Down

0 comments on commit 0b8d314

Please sign in to comment.