Who can comment the following:
import json, urllib
url = "funnyfurniture.net/p/10/oops-chair/"
url2 = "http://funnyfurniture.net/p/10/oops-chair/"
tw_url = "http://urls.api.twitter.com/1/urls/count.json?url=%s" %url
tw_url2 = "http://urls.api.twitter.com/1/urls/count.json?url=%s" %url2
js2 = json.load(urllib.urlopen(tw_url))
js = json.load(urllib.urlopen(tw_url2))
print js2, js
Gives
{u'count': 0, u'url': u'http://funnyfurniture.net/p/10/oops-chair/'} {u'count': 1, u'url': u'http://funnyfurniture.net/p/10/oops-chair/'}
What is the difference??
The standard v1. 1 endpoints were launched in 2012 and enables you to post, interact, and retrieve data for resources such as Tweets, Users, Direct Messages, Lists, Trends, Media, and Places.
As users work through these flows, they need a web page or location to be sent to after they have successfully logged in and provided authorization to the developer's App. This follow-up webpage or location is called a callback URL.
In order for you to get the Twitter feed working you need four keys; the Consumer Key, Consumer Secret, Access Token and Access Token Secret. Below are the steps to get those 4 keys. Go to https://apps.twitter.com/app/new and log in, if necessary.
The Twitter API normalizes urls, so when you pass in cnn.com
it converts it to http://cnn.com
automatically:
% curl 'http://urls.api.twitter.com/1/urls/count.json?url=foo'
{"count":0,"url":"http://foo/"}
The discrepancy in the counts you saw may have been a temporary bug on Twitter's side, e.g. calculating the counts before normalizing the urls.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With