Permalink
Browse files

only spits out list of URLs now, tumblr

  • Loading branch information...
1 parent 434ffe5 commit f7d452c2a3b2cbe189124cfff810cdeb65add8a5 Nancy Ouyang committed Mar 25, 2012
Showing with 16 additions and 5 deletions.
  1. +10 −0 README
  2. +6 −5 tumblr_api.py
View
10 README
@@ -28,3 +28,13 @@ testAPI.ProjectsNearLatLong(40.776104,-73.920822)
http://api.donorschoose.org/common/json_feed.html?&APIKey=DONORSCHOOSE&centerLat=40.776104&centerLng=-73.920822
{u'index': u'0', u'max': u'10', u'proposals': [{u'totalPrice': u'273.85', u'percentFunded': u'0', u'schoolName': u'Ps 122 Mamie Fay', u'fundURL': u'https://secure.donorschoose.org/donors/givingCart.html?proposalid=718970&donationAmount=&utm_source=api&utm_medium=feed&utm_content=fundlink&utm_campaign=DONORSCHOOSE', u'expirationDate': u'2012-06-13', u'proposalURL': u'http://www.donorschoose.org/donors/proposal.html?id=718970&utm_source=api&utm_medium=
+~~~
+Tumblr API
+
+import tumblr_api
+from tumblr_api import (Tumblr_API, Posts)
+testAPI = tumblr_api.Posts()
+testAPI.PhotosFromUser('nyancatwashere')
+
+=> Sample Results
+[u'http://27.media.tumblr.com/tumblr_lvhtm8h3CL1qm280wo1_500.jpg', u'http://30.media.tumblr.com/tumblr_lvhtpgBwNn1qm280wo1_400.jpg', u'http://29.media.tumblr.com/tumblr_lvhtoffPoR1qm280wo1_400.jpg', u'http://30.media.tumblr.com/tumblr_lvhtmtnnHQ1qm280wo1_500.jpg', u'http://www.tumblr.com/photo/1280/nyancatwashere/13972524882/1/tumblr_lvhtk0mw281qm280w', u'http://www.tumblr.com/photo/1280/nyancatwashere/13925449117/1/tumblr_lvhacjq8A31qm280w', ...
View
@@ -48,21 +48,22 @@ def __init__(self):
def call_api(self, directory):
url_list = [self.base_url]
+ url_list.append('/%s' % str(directory))
url_list.append('/posts/photo?&api_key=%s' % API_KEY)
- url_list.append('&%s' % str(directory))
url = ''.join(url_list)
print url
r = requests.get(url)
j = json.loads(r.content)
- #proposals = j["proposals"]
- #results = [x["title"] for x in proposals]
- #return results
+ response = j["response"]
+ listposts = response["posts"]
+ urlpics = [ x["photos"][0]["original_size"]["url"] for x in listposts]
+ return urlpics
class Posts(Tumblr_API):
def __init__(self):
- self.base_url = 'http://api.tumblr.com/v2/blog/'
+ self.base_url = 'http://api.tumblr.com/v2/blog'
def PhotosFromUser(self, username):
"""

0 comments on commit f7d452c

Please sign in to comment.