Exemplo n.º 1
0
 def get_recent_copies(self):
     " Get a list of X most recent copies for the profile. "
     # Only run requests for auth'd users w/ linked appropriate token values
     if not self.key or not self.secret or not self.verifier or not self.is_approved:
         return []
         
     # Create the OAuthRequest
     access_token = oauth.OAuthToken(self.key, self.secret)
     oauth_request = oauth.OAuthRequest.from_consumer_and_token(
         consumer, 
         token=access_token, 
         http_method='GET', 
         http_url=GET_USER_COPY_DATA_URL
     )
     oauth_request.sign_request(signature_method_plaintext, consumer, access_token)
     response = sample_client.access_resource(oauth_request)
     
     # Dump the json response and return the list of copy_data
     try:
         json = simplejson.loads(response)
         return json['copy_data']
     except simplejson.JSONDecodeError:
         return []