Skip to content

Commit

Permalink
Added API Usage to the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Henrik Lied authored and Henrik Lied committed Mar 8, 2009
1 parent 420ee5f commit fd1483a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,26 @@
Use the API resources listed on the [REST API Documentation](http://apiwiki.twitter.com/REST+API+Documentation).
I've currently implemented two functions, which you can see in the end of twitter_app/utils.py.

**Example:**
Here's how you might implement a delete method:

def delete_status_message(consumer, connection, access_token, tweet_id):
oauth_request = request_oauth_resource(consumer, 'http://twitter.com/statuses/destroy/%s.json' % tweet_id, access_token)
json = fetch_response(oauth_request, connection)
return json


Then, in your views.py, you could define a simplistic function like so:
def delete_tweet(request, tweet_id):
access_token = request.session.get('access_token', None)
if not access_token:
return HttpResponse("You need an access token!")
token = oauth.OAuthToken.from_string(access_token)

message = delete_status_message(CONSUMER, CONNECTION, token, tweet_id)
if message:
message = simplejson.loads(message)
return return render_to_response('twitter_app/delete_tweet.html', {'message': message})

## Installation
Add the 'twitter_app' directory somewhere on your 'PYTHONPATH', put it into 'INSTALLED_APPS' in your settings file.
Fill in your CONSUMER_KEY and CONSUMER_SECRET either in 'twitter_app/utils.py' or in your settings file.
Expand Down

0 comments on commit fd1483a

Please sign in to comment.