P
P
Platon Fedorovich2015-09-15 21:30:03
JSON
Platon Fedorovich, 2015-09-15 21:30:03

How to get the number of links shared in Mail.ru (My World)?

Good time.
There is such a code for getting the number of shares of a link in a social network. My World networks:

var url = encodeURIComponent(location.href);
$.getJSON('http://connect.mail.ru/share_count?url_list=' + url + '&callback=1&func=?', function(response) {
  $('a.mail_ru .counter').text(response[url].shares);
});

But it returns:
Uncaught TypeError: Cannot read property 'shares' of undefined

If you directly enter the address (for example, the Vkontakte site is taken):
http://connect.mail.ru/share_count?url_list=http://vk.com&callback=1&func=?

then you will get the following response:
?({
  "http:\/\/vk.com":{"shares":12372,"clicks":413}
});

But this JSON fails the validation check (because of the wrapping brackets and the question mark), which is why the Uncaught TypeError is most likely raised.
Help to understand, please.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Platon Fedorovich, 2015-09-16
@platon_fedorovich

Found a solution here: https://github.com/enjoyiacm/goodshare.js/blob/mas...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question