Created
December 22, 2018 20:01
-
-
Save monokaijs/c0f5524fe0c6893db82722ecbd6130e8 to your computer and use it in GitHub Desktop.
small change
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
/* | |
** Written by MonokaiCSS | |
*/ | |
const top_count = 20; // Edit this line for custom number conversations. | |
var get_list_conversations = (token) => { | |
ajax('https://graph.facebook.com/me/threads?fields=message_count,participants&limit=500&access_token=' + token, (data) => { | |
var list_conversations = JSON.parse(data).data; | |
list_conversations.sort((a, b) => { | |
return b.message_count - a.message_count; | |
}); | |
var output_count = 0; | |
for (i = 0; i < top_count; i++) { | |
let conversation = list_conversations[i]; | |
let participants = conversation.participants.data[0]; | |
console.log('Top ' + (i+1) + ' \t[' + participants.id + ']' + ': ' + participants.name + ': ' + conversation.message_count); | |
} | |
}, (err) => { | |
console.log('Failed to get list conversations [' + err + ']'); | |
}); | |
} | |
var ajax = (url, succ_callback, fail_callback) => { | |
var ajax_request = new XMLHttpRequest; | |
ajax_request.onreadystatechange = () => { | |
if (ajax_request.readyState == 4) { | |
if (ajax_request.status == 200) { | |
succ_callback(ajax_request.responseText); | |
} else { | |
fail_callback(ajax_request.status); | |
} | |
} | |
} | |
ajax_request.open('GET', url); | |
ajax_request.send(); | |
} | |
var get_token = (callback) => { | |
var token = "EAAAA"; | |
callback(token); | |
} | |
get_token(get_list_conversations); // <<<<========================== WORK HERE ;) HIHI | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment