Example #1
0
File: oauth.py Project: svven/web
 def callback(self):
     request_token = session.pop('request_token')
     if 'oauth_verifier' not in request.args:
         return None
     oauth_session = self.service.get_auth_session(
         request_token[0], request_token[1],
         data={'oauth_verifier': request.args['oauth_verifier']}
     )
     user = User.parse(None, 
         oauth_session.get('account/verify_credentials.json').json())
     key = oauth_session.access_token
     secret = oauth_session.access_token_secret
     return user, key, secret
Example #2
0
File: oauth.py Project: svven/web
 def callback(self):
     request_token = session.pop('request_token')
     if 'oauth_verifier' not in request.args:
         return None
     oauth_session = self.service.get_auth_session(
         request_token[0],
         request_token[1],
         data={'oauth_verifier': request.args['oauth_verifier']})
     user = User.parse(
         None,
         oauth_session.get('account/verify_credentials.json').json())
     key = oauth_session.access_token
     secret = oauth_session.access_token_secret
     return user, key, secret
 def parse_follow_unfollow_event(self, data):
     """
     if data is follow or unfollow event-object then return parsed event-object,
     else return False.
     """
     if '"event":"follow"' not in data and '"event":"unfollow"' not in data:
         return False
     jobj = json.loads(data)
     if 'event' not in jobj or 'created_at' not in jobj or 'target' not in jobj:
         return False
     event_name = jobj['event']
     if event_name != 'follow' and event_name != 'unfollow':
         return False
     target = User.parse(self.api, jobj['target'])
     if event_name == 'follow' and target.id == self.my_id:  # User is followed
         return False
     created_at = parse_datetime(jobj['created_at'])
     return dict(event_name=event_name, created_at=created_at, target=target)
    def parse_status_event(self, data):
        """
        if status contains user-object then return parsed user-object,
        else return False.

        ** NOTE **
        this method treats tweet and RT,
        but other data also contains '"in_reply_to_status_id":', e.g. fav.
        """
        if '"in_reply_to_status_id":' not in data:
            return False
        jobj = json.loads(data)
        if 'user' not in jobj or 'created_at' not in jobj:
            return False
        user = User.parse(self.api, jobj['user'])
        if user.id != self.my_id and user.id not in self.friends:
            return False
        created_at = parse_datetime(jobj['created_at'])
        return dict(user=user, created_at=created_at)
Example #5
0
 def on_data(self, raw_data):
     data = json.loads(raw_data)
     status = User.parse(self.api, data)
     location = status.user['location']
     if location == None:
         location = 'No Activado'
         print(location)
     # ------------------#
     print(location)
     print(status)
     # print(status.user['name']+': '+ status.text)
     creado = status.created_at
     id = status.id
     nom = status.user['name']
     tweet = status.text
     cursor.execute(
         '''INSERT INTO USUARIO(ID, NOMBRE, TWEETS, CREADO) VALUES(?,?,?,?)''',
         (id, nom, tweet, creado))
     db.commit()
     return (True)
Example #6
0
 def me(self):
     return User.parse(self, fewerror_user)
Example #7
0
 def on_data(self, raw_data):
     data = json.loads(raw_data)
     status = User.parse(self.api, data)
     tweet = status.text
     print(tweet)
     return (True)