Skip to content

Instantly share code, notes, and snippets.

@victorono
Created February 14, 2014 16:02
Show Gist options
  • Save victorono/9003650 to your computer and use it in GitHub Desktop.
Save victorono/9003650 to your computer and use it in GitHub Desktop.
Count share url in twitter and facebook
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests
url = "http://urls.api.twitter.com/1/urls/count.json"
params = dict(
url='http://www.google.com'
)
resp = requests.get(url=url, params=params)
json_result = resp.json()
print "Share twitter: %s" % json_result['count']
url = "http://api.facebook.com/restserver.php"
params = dict(
method='links.getStats',
urls='http://www.google.com',
format='JSON'
)
resp = requests.get(url=url, params=params)
json_result = resp.json()
print "Share facebook: %s" % json_result[0]['share_count']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment