Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

twitter api: What is the difference in following urls

Tags:

twitter

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??

like image 262
Oleg Tarasenko Avatar asked Apr 21 '11 14:04

Oleg Tarasenko


People also ask

What are endpoints in Twitter API?

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.

What is a Twitter callback URL?

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.

What are the 4 main Twitter keys?

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.


1 Answers

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.

like image 63
samplebias Avatar answered Dec 13 '22 04:12

samplebias