How to use add_url API

I’ve started playing with the API using Python Requests but cannot figure out how to use /reader/add_url properly. Why does the following code get a 403 response for add_url?

 
login = requests.post('http://www.newsblur.com/api/login', {'username': 'exampleuser', 'password': 'passw0rd'})   
print '/api/login', login   
 
addurl = requests.post('http://www.newsblur.com/reader/add\_url', {'url' : 'http://blog.newsblur.com'})   
print '/reader/add\_url', addurl   
 
logout = requests.post('http://www.newsblur.com/api/logout')   
1 Like

There are two ways to do this. First is the easy way: use the NewsBlur Python API: http://github.com/samuelclay/NewsBlur…. It uses urllib2, but the important part is the cookieJar it uses.

When you make that login call, you are given a cookie back, called “newsblur_sessionid”. You want to hold on to that cookie for subsequent calls. Requests allows you to do this quite easily. It’s called sessions and it bakes in this cookie passing: http://docs.python-requests.org/en/la…

If you roll your own ad hoc API, just use requests.session() and you’ll be golden. And let me know what you’re building. I’d love to help out if I can.

Hi Sam

To be honest, I was just playing with Python and Requests, and happened to remember that Newsblur has a Python API.

I may actually write an Ubuntu app though. I’ll let you know when I have something to test.