Commits

Martin Skala committed 2e96c39

Comply twitter_roa with Twitter API (only a proof of concept)

  • Participants
  • Parent commits 63e1b16

Comments (0)

Files changed (3)

examples/twitter_roa/models.py

 from django_roa.db.query import RemoteQuerySet
 
 class User(Model):
-    name = models.CharField(max_length=50)
-    screen_name = models.CharField(max_length=50)
+    name = models.CharField(max_length=255)
+    screen_name = models.CharField(max_length=255)
     description = models.TextField()
 
     def __unicode__(self):
 
     @staticmethod
     def get_resource_url_list():
-        return u'http://twitter.com/users/show.json'
+        return u'http://api.twitter.com/1/users/lookup.json?screen_name=twitterapi,twitter,twittersearch,twittermedia,twittermobile'
+    
+    def get_resource_url_count(self):
+        return User.get_resource_url_list()
 
 
 class FakeCountRemoteQuerySet(RemoteQuerySet):
 
     @staticmethod
     def get_resource_url_list():
-        return u'http://twitter.com/statuses/public_timeline.json'
+        return u'http://api.twitter.com/1/statuses/public_timeline.json'

examples/twitter_roa/serializers.py

         object_list = [object_list]
     for obj in object_list:
         # Look up the model and starting build a dict of data for it.
-        if 'name' in obj:
+        if 'screen_name' in obj:
             Model = _get_model('twitter_roa.user')
         else:
             Model = _get_model("twitter_roa.tweet")
             # Handle all other fields
             else:
                 data[field.name] = field.to_python(field_value)
-        
         yield base.DeserializedObject(Model(**data), m2m_data)

examples/twitter_roa/settings.py

 ROA_DJANGO_ERRORS = True # useful to ease debugging if you use test server
 
 ROA_URL_OVERRIDES_DETAIL = {
-    'twitter_roa.tweet': lambda o: u'http://twitter.com/statuses/show/%s.json' % o.id,
-    'twitter_roa.user': lambda o: u'http://twitter.com/users/show/%s.json' % o.id,
+    'twitter_roa.tweet': lambda o: u'http://api.twitter.com/1/statuses/show/%s.json' % o.id,
+    'twitter_roa.user': lambda o: u'http://api.twitter.com/1/users/show.json?user_id=%s' % o.id,
 }
 ROA_ARGS_NAMES_MAPPING = {
     'filter_id__exact': 'user_id',
 }
+ROA_CUSTOM_ARGS = {
+    'include_entities': 'false',
+    'skip_status': 'true',
+}
 
 ## Logging settings
 import logging