Posts Tagged ‘api’

friendfeed.py Patch for use on Google App Engine

Thursday, May 29th, 2008

Ask and ye shall receive.  Attached is a patch for using friendfeed.py on Google App Engine.  You need to also have demjson available.  Google App Engine does not allow use of many C modules (like cjson) and both json and simplejson will throw decoding errors from time to time. demjson is slow but won’t throw errors around (I really wish we could use cjson; it’s so much faster).

Basically the differences are:

  1. Use urlfetch instead of urllib2
  2. Use Django’s urlencode which will work with unicode (letting you comment/share in languages like Chinese)
  3. Use demjson instead of cjson (which cannot be used on Google App Engine), simplejson, or json (which both throw decoding errors from time to time)

Enjoy!

Update:

You don’t need to use demjson anymore; simplejson will work just fine.  I just got an email from Sanjeev saying that they fixed the issue (’\x’ is not valid JSON).  This makes things even easier because simplejson is included in Django (from django.utils import simplejson) which is included in Google App Engine.

JSON Callbacks for RSSmeme API

Wednesday, May 14th, 2008

The RSSmeme API now supports JSON callbacks.  Just place an additional parameter ‘callback’ onto the end of the URL to set the callback function name.  This will let you use the API in JavaScript.  Here is an example:

http://www.rssmeme.com/api/?output=json&callback=foo

This came from a user request.  I figured eventually someone would ask for it so there you are!

Ophthalmologists and Divers Love RSSmeme

Tuesday, May 13th, 2008

68.180.194.243 - - [13/May/2008:15:04:48 -0400] "GET /api/?output=atom&feeds_gte=3&search=ophthalmologist HTTP/1.0" 200 196 "-" "Yahoo Pipes 1.0"
68.180.194.243 - - [13/May/2008:15:04:48 -0400] "GET /api/?output=atom&feeds_gte=3&search=optics HTTP/1.0" 200 196 "-" "Yahoo Pipes 1.0"
68.180.194.243 - - [13/May/2008:15:04:48 -0400] "GET /api/?output=atom&feeds_gte=3&search=optician HTTP/1.0" 200 196 "-" "Yahoo Pipes 1.0"
68.180.194.243 - - [13/May/2008:15:04:48 -0400] "GET /api/?output=atom&feeds_gte=3&search=optometrist HTTP/1.0" 200 196 "-" "Yahoo Pipes 1.0"
68.180.194.243 - - [13/May/2008:15:04:48 -0400] "GET /api/?output=atom&feeds_gte=3&search=optic HTTP/1.0" 200 196 "-" "Yahoo Pipes 1.0"
68.180.194.243 - - [13/May/2008:15:04:48 -0400] "GET /api/?output=atom&feeds_gte=3&search=eyeball HTTP/1.0" 200 2678 "-" "Yahoo Pipes 1.0"
68.180.194.243 - - [13/May/2008:15:04:48 -0400] "GET /api/?output=atom&feeds_gte=3&search=eyeglasses HTTP/1.0" 200 1620 "-" "Yahoo Pipes 1.0"
68.180.194.243 - - [13/May/2008:15:04:48 -0400] "GET /api/?output=atom&feeds_gte=3&search=eyeballs HTTP/1.0" 200 4271 "-" "Yahoo Pipes 1.0"
68.180.194.243 - - [13/May/2008:15:04:48 -0400] "GET /api/?output=atom&feeds_gte=3&search=optical HTTP/1.0" 200 12622 "-" "Yahoo Pipes 1.0"
69.147.112.169 - - [13/May/2008:15:08:30 -0400] "GET /api/?output=atom&feeds_gte=4&search=snorkeling HTTP/1.0" 200 196 "-" "Yahoo Pipes 1.0"
69.147.112.169 - - [13/May/2008:15:08:31 -0400] "GET /api/?output=atom&feeds_gte=4&search=scuba HTTP/1.0" 200 196 "-" "Yahoo Pipes 1.0"
69.147.112.169 - - [13/May/2008:15:08:30 -0400] "GET /api/?output=atom&feeds_gte=4&search=snorkelling HTTP/1.0" 200 196 "-" "Yahoo Pipes 1.0"
69.147.112.169 - - [13/May/2008:15:08:30 -0400] "GET /api/?output=atom&feeds_gte=4&search=divers HTTP/1.0" 200 196 "-" "Yahoo Pipes 1.0"
69.147.112.169 - - [13/May/2008:15:08:30 -0400] "GET /api/?output=atom&feeds_gte=4&search=snorkel HTTP/1.0" 200 196 "-" "Yahoo Pipes 1.0"
69.147.112.169 - - [13/May/2008:15:08:30 -0400] "GET /api/?output=atom&feeds_gte=4&search=underwater HTTP/1.0" 200 2093 "-" "Yahoo Pipes 1.0"
69.147.112.169 - - [13/May/2008:15:08:30 -0400] "GET /api/?output=atom&feeds_gte=4&search=diver HTTP/1.0" 200 1267 "-" "Yahoo Pipes 1.0"
69.147.112.169 - - [13/May/2008:15:08:31 -0400] "GET /api/?output=atom&feeds_gte=4&search=dive HTTP/1.0" 200 3626 "-" "Yahoo Pipes 1.0"
69.147.112.169 - - [13/May/2008:15:08:30 -0400] "GET /api/?output=atom&feeds_gte=4&search=diving HTTP/1.0" 200 11392 "-" "Yahoo Pipes 1.0"
69.147.112.169 - - [13/May/2008:15:08:31 -0400] "GET /api/?output=atom&feeds_gte=4&tag=snorkel HTTP/1.0" 200 196 "-" "Yahoo Pipes 1.0"
69.147.112.169 - - [13/May/2008:15:08:31 -0400] "GET /api/?output=atom&feeds_gte=4&tag=snorkelling HTTP/1.0" 200 196 "-" "Yahoo Pipes 1.0"
69.147.112.169 - - [13/May/2008:15:08:31 -0400] "GET /api/?output=atom&feeds_gte=4&tag=diving HTTP/1.0" 200 1267 "-" "Yahoo Pipes 1.0"
69.147.112.169 - - [13/May/2008:15:08:31 -0400] "GET /api/?output=atom&feeds_gte=4&tag=snorkeling HTTP/1.0" 200 196 "-" "Yahoo Pipes 1.0"
69.147.112.169 - - [13/May/2008:15:08:31 -0400] "GET /api/?output=atom&feeds_gte=4&tag=dive HTTP/1.0" 200 869 "-" "Yahoo Pipes 1.0"
69.147.112.169 - - [13/May/2008:15:08:31 -0400] "GET /api/?output=atom&feeds_gte=4&tag=diver HTTP/1.0" 200 196 "-" "Yahoo Pipes 1.0"
69.147.112.169 - - [13/May/2008:15:08:31 -0400] "GET /api/?output=atom&feeds_gte=4&tag=scuba HTTP/1.0" 200 196 "-" "Yahoo Pipes 1.0"
69.147.112.169 - - [13/May/2008:15:08:31 -0400] "GET /api/?output=atom&feeds_gte=4&tag=divers HTTP/1.0" 200 4301 "-" "Yahoo Pipes 1.0"
69.147.112.169 - - [13/May/2008:15:08:31 -0400] "GET /api/?output=atom&feeds_gte=4&tag=underwater HTTP/1.0" 200 3695 "-" "Yahoo Pipes 1.0"

Someone is building up quite the Yahoo Pipe!  Seriously nice to see the API getting use.  Are you using the API? Let me know how it’s working out for you!

Mobile RSSmeme

Sunday, May 11th, 2008

This morning I built a mobile RSSmeme using the RSSmeme API.  It is only 50 lines of templates and code in order to generate this page.  It is simply a mobile representation of the RSSmeme front page.  See how easy it is to work with the API?

Here’s the code:

import urllib2
from django.core.cache import cache
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.utils import simplejson

CACHE_TIME = 60 * 5

def home(request):
    URL = 'http://www.rssmeme.com/?output=json&language=en'
    key = URL
    json = cache.get(key)
    if not json:
        json = simplejson.load(urllib2.urlopen(URL))
        cache.set(key, json, CACHE_TIME)
    return render_to_response('base.html', {'entries': json['entries']}, context_instance = RequestContext(request))

And base.html is just a simple template.  There’s nothing to it!

How to Use the RSSmeme API to Pull Notes into Wordpress

Friday, May 9th, 2008

I’d like for someone to write a Wordpress plugin that will pull all of the notes for an article out of RSSmeme.  The JSON API is now ready for it.  Here’s a quick “how to” to get your rolling:

  1. Build your URL.  You want to operate on http://www.rssmeme.com/api/ so you have no “built in” filter on pub_date like the front page does.  Let’s get all the notes for the current top story on RSSmeme.  The URL we’d build is this:

    http://www.rssmeme.com/api/?output=json&url=http://ejohn.org/blog/processingjs/

  2. That URL will give us some JSON that we can then parse.  The format is very similar to the FriendFeed API.  It is basically one big dictionary.  You can see there is an ‘entries’ key that has list of entries (in our case there is only 1 item in the list because we are filtering for a specific url).  That entry is another dictionary that contains a key ‘notes’.  Under ‘notes’ is a list of dictionaries containing information about the note.  It gives you the author of the note (called a feed because the note came from a feed object) and the content of the note.  The author of the note is also a dictionary containing information like their id in RSSmeme, a link to their Google Reader shared page, and their name.

That’s all it should take!  Please be kind to my server; try to cache whatever you pull out of it.  RSSmeme caches data for 10 minutes so make sure your cache is at least that long.

Enjoy!  Please ask any questions you may have.