Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added support for user's/friends activities

  • Loading branch information...
commit 22163dbe4093d91707be8301b096e5eb765d6bae 1 parent 4c4f5d8
cnanga authored
Showing with 15 additions and 2 deletions.
  1. +15 −2 myspaceid-python-sdk/src/myspace/myspaceapi.py
View
17 myspaceid-python-sdk/src/myspace/myspaceapi.py
@@ -45,6 +45,9 @@
API_STATUS_URL = 'http://api.myspace.com/v1/users/%s/status.json'
API_VIDEOS_URL = 'http://api.myspace.com/v1/users/%s/videos.json'
API_VIDEO_URL = 'http://api.myspace.com/v1/users/%s/videos/%s.json'
+API_ACTIVITIES_URL = "http://api.myspace.com/v1/users/%s/activities.atom"
+API_FRIENDSACTIVITIES_URL = "http://api.myspace.com/v1/users/%s/friends/activities.atom"
+
class MySpaceError(Exception):
def __init__(self, message, http_response=None):
@@ -179,6 +182,16 @@ def get_video(self, user_id, video_id):
self.__validate_params(locals())
video_request_url = API_VIDEO_URL % (user_id, video_id)
return self.__call_myspace_api(video_request_url)
+
+ def get_activities_atom(self, user_id):
+ self.__validate_params(locals())
+ activities_request_url = API_ACTIVITIES_URL % user_id
+ return self.__call_myspace_api(activities_request_url, get_raw_response=True)
+
+ def get_friends_activities_atom(self, user_id):
+ self.__validate_params(locals())
+ activities_request_url = API_FRIENDSACTIVITIES_URL % user_id
+ return self.__call_myspace_api(activities_request_url, get_raw_response=True)
"""Miscellaneous utility functions
"""
@@ -213,7 +226,7 @@ def __call_oauth_api(self, oauth_url, token=None, debug=False):
raise MySpaceError('MySpace OAuth API returned an error', resp)
return resp.body
- def __call_myspace_api(self, api_url, parameters=None, debug=False):
+ def __call_myspace_api(self, api_url, parameters=None, debug=False, get_raw_response=False):
#Check to make sure the contructor was call called with the access_token
#before making API calls
if self.token is None:
@@ -227,7 +240,7 @@ def __call_myspace_api(self, api_url, parameters=None, debug=False):
resp = self.url_fetcher.fetch(oauth_request.to_url())
if resp.status is not 200:
raise MySpaceError('MySpace REST API returned an error', resp)
- api_response = simplejson.loads(resp.body)
+ api_response = resp.body if get_raw_response else simplejson.loads(resp.body)
return api_response
class UrlFetcher(object):
Please sign in to comment.
Something went wrong with that request. Please try again.