Skip to content

Commit

Permalink
Merge pull request #41 from tavva/add-delete-requests-support
Browse files Browse the repository at this point in the history
Add a method to delete application requests.
  • Loading branch information
martey committed Aug 6, 2012
2 parents c0701d0 + 871ad0e commit 25c4dab
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions facebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import time
import urllib
import urllib2
import httplib
import hashlib
import hmac
import base64
Expand Down Expand Up @@ -169,6 +170,28 @@ def delete_object(self, id):
"""Deletes the object with the given ID from the graph."""
self.request(id, post_args={"method": "delete"})

def delete_request(self, user_id, request_id):
"""Deletes the Request with the given ID for the given user."""
conn = httplib.HTTPSConnection('graph.facebook.com')

url = '/%s_%s?%s' % (
request_id,
user_id,
urllib.urlencode({'access_token': self.access_token}),
)
conn.request('DELETE', url)
response = conn.getresponse()
data = response.read()

response = _parse_json(data)
# Raise an error if we got one, but don't not if Facebook just
# gave us a Bool value
if (response and isinstance(response, dict) and
response.get("error")):
raise GraphAPIError(response)

conn.close()

def put_photo(self, image, message=None, album_id=None, **kwargs):
"""Uploads an image using multipart/form-data.
Expand Down

0 comments on commit 25c4dab

Please sign in to comment.