Answer the question
In order to leave comments, you need to log in
The general principle (algorithm) of authorization through social networks and sending comments, like hypercomments and cackle?
Hello!
I've been struggling for some time to figure out how best to implement a social media comment system. Unfortunately, having picked up a mess of knowledge in PHP and JavaScript, I have serious suspicions that the algorithm I have chosen leads nowhere :)
Therefore, I would like to ask an authoritative opinion on some specific points.
I'll make a reservation right away that I'm trying to implement JavaScript authorization and sending comments without reloading the page.
For now, I will limit myself to one question. For clarity, I will give an example using the Vkontakte JavaScript API:
1. When a user enters the site, the algorithm should check if he is already authorized through my Vkontakte application ( VK.Auth.getLoginStatus)? The problem is that before we have the opportunity to do such a check, the Vkontakte API must be initialized on the site, and asynchronously, so as not to interfere with the work of other scripts and the formation of the DOM tree. The only thing I've come up with so far is to put VK.Auth.getLoginStatus into this construct:
var intervalVKId = setInterval(
function () {
var vk_counter = $('#vk_counter').text();
vk_counter++;
$('#vk_counter').text(vk_counter);
if (typeof VK === 'object') {
VK.Auth.getLoginStatus(function(response) {
if (response.session) {
getVKUser(response.session.mid);
$('#vk').attr('status','login');
} else {
$('#vk').attr('status','logoff');
}
clearInterval(intervalVKId);
});
}
if ($('#vk').attr('status') == 'logoff'
|| $('#vk').attr('status') == 'login'
|| $('#vk_counter').text() > 50) {
setTimeout(function() {
clearInterval(intervalVKId);
}, 100);
}
}, 100);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question