timrael / social_shares Goto Github PK
View Code? Open in Web Editor NEWCheck how many times url was shared in social networks, e.g. share counts
License: MIT License
Check how many times url was shared in social networks, e.g. share counts
License: MIT License
Set them to about 3-6sec
Links like this doesn't works
https://slon.ru/posts/61533?utm_source=slon.ru&utm_medium=rss&utm_campaign=all
And this works
https://slon.ru/posts/61533
{
try
{
$curl_response = $this->curl->get("https://graph.facebook.com/v2.1/?" . $domain);
if ($curl_response->headers['Status-Code'] == "200") {
$parse_response = json_decode($curl_response, true);
$fb_share_count = $parse_response['share'][0]['share_count'];
$fb_like_count = $parse_response['share'][0]['like_count'];
$fb_comment_count = $parse_response['share'][0]['comment_count'];
} else {
$fb_share_count = 0;
$fb_like_count = 0;
$fb_comment_count = 0;
}
$response = array(
'status' => 'success',
'data' => array(
'fb_share_count' => filter_var($fb_share_count, FILTER_SANITIZE_NUMBER_INT),
'fb_like_count' => filter_var($fb_like_count, FILTER_SANITIZE_NUMBER_INT),
'fb_comment_count' => filter_var($fb_comment_count, FILTER_SANITIZE_NUMBER_INT)
)
);
}
catch (Exception $e)
{
$response = array(
'status' => 'error',
'msg' => $e->getMessage()
);
}
return $response;
}```
Redis?
Just came across your gem. Neat. Noticed that facebook returns the same count regardless of URL scheme (http vs https). Twitter, Reddit, and Pinterest (maybe others) have different counts.
Should those that change be tweaked to check both http and https and sum the count? If there's an interest in that I'd be willing to submit a PR.
I got this error "Error during requesting sharings of...".
I'm wondering weather it happens because of request is limited or another reason.
I gets this errorRestClient::Forbidden: 403 Forbidden
from /Users/ipatov/.rvm/gems/ruby-2.3.0/gems/rest-client-2.0.1/lib/restclient/abstract_response.rb:223:in exception_with_response' from /Users/ipatov/.rvm/gems/ruby-2.3.0/gems/rest-client-2.0.1/lib/restclient/abstract_response.rb:103:in
return!'
from /Users/ipatov/.rvm/gems/ruby-2.3.0/gems/rest-client-2.0.1/lib/restclient/request.rb:809:in process_result' from /Users/ipatov/.rvm/gems/ruby-2.3.0/gems/rest-client-2.0.1/lib/restclient/request.rb:725:in
block in transmit'
from /Users/ipatov/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/net/http.rb:853:in start' from /Users/ipatov/.rvm/gems/ruby-2.3.0/gems/rest-client-2.0.1/lib/restclient/request.rb:715:in
transmit'
from /Users/ipatov/.rvm/gems/ruby-2.3.0/gems/rest-client-2.0.1/lib/restclient/request.rb:145:in execute' from /Users/ipatov/.rvm/gems/ruby-2.3.0/gems/rest-client-2.0.1/lib/restclient/request.rb:52:in
execute'
from /Users/ipatov/.rvm/gems/ruby-2.3.0/gems/rest-client-2.0.1/lib/restclient/resource.rb:51:in get' from /Users/ipatov/.rvm/gems/ruby-2.3.0/gems/social_shares-0.3.2/lib/social_shares/base.rb:48:in
get'
from /Users/ipatov/.rvm/gems/ruby-2.3.0/gems/social_shares-0.3.2/lib/social_shares/facebook.rb:6:in shares!' from /Users/ipatov/.rvm/gems/ruby-2.3.0/gems/social_shares-0.3.2/lib/social_shares.rb:54:in
block (2 levels) in singleton class'
from /Users/ipatov/.rvm/gems/ruby-2.3.0/gems/social_shares-0.3.2/lib/social_shares.rb:119:in block (2 levels) in selected_base' from /Users/ipatov/.rvm/gems/ruby-2.3.0/gems/social_shares-0.3.2/lib/social_shares.rb:113:in
block (2 levels) in thread_pool'
The current used method for getting facebook shares will not work as the FQL API was recently deprecated. You'll get the following error message: "(#12) fql is deprecated for versions v2.1 and higher"
As a (poor) alternative I suggest looking at the following API:
https://graph.facebook.com/?id=http://google.com&fields=id,og_object{image,engagement,likes.summary(true),comments.summary(true).limit(100)},share
I created a sinatra app using this gem. After a while I noticed it was eating memory on the server like crazy. I forked and removed the threading, which resolved the issue.
I did try to solve it and keep threads but no luck. I think its related to something like this. I'll have another go at fixing it if I get the time.
Urls like this doesn't work if you count vkontakte shares
http://top.rbc.ru/politics/15/02/2015/54e0793a9a7947c1231b4967#xtor=AL-[internal_traffic]--[rss.rbc.ru]-[top_stories]
This works
http://top.rbc.ru/politics/15/02/2015/54e0793a9a7947c1231b4967
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.