Example #1
0
 def get_username(self):
     if self.username is None:
         api = API(self)
         user = api.verify_credentials()
         if user:
             self.username = user.screen_name
         else:
             raise WeibopError("Unable to get username, invalid oauth token!")
     return self.username
Example #2
0
 def get_username(self):
     if self.username is None:
         api = API(self)
         user = api.verify_credentials()
         if user:
             self.username = user.screen_name
         else:
             raise WeibopError(
                 "Unable to get username, invalid oauth token!")
     return self.username
Example #3
0
 def __init__(self,
              username,
              password,
              listener,
              timeout=5.0,
              retry_count=None,
              retry_time=10.0,
              snooze_time=5.0,
              buffer_size=1500,
              headers=None):
     self.auth = BasicAuthHandler(username, password)
     self.running = False
     self.timeout = timeout
     self.retry_count = retry_count
     self.retry_time = retry_time
     self.snooze_time = snooze_time
     self.buffer_size = buffer_size
     self.listener = listener
     self.api = API()
     self.headers = headers or {}
     self.body = None
Example #4
0
'''
Created on 2011-3-22

@author: LiuTao
'''
from weibo.weibopy import auth
from weibo.weibopy.api import API
from util import sqlite_db

if __name__ == '__main__':

    wei_bo = sqlite_db.WeiBo({"path": "db", "autocommit": True})
    #    wei_bo.create_db()

    #    wei_bo.setConsumerToken({'app_key':'168563670', 'app_secret':'f974cc11afd8cde62ff845d0860ceda2'})
    #    wei_bo.setAccessToken({'uid':1, 'access_key':"2756ed2fea9e36f46fba2dd748f13872", 'access_secret':'0b142a1e8538729158a7f01f0aebeab4'})

    app_token = wei_bo.getConsumerToken()
    access_token = wei_bo.getAccessToken(1)

    oauth_handler = auth.OAuthHandler(app_token[0][0], app_token[0][1])
    oauth_handler.set_access_token(access_token[0][0], access_token[0][1])
    client = API(oauth_handler)

    timeline = client.friends_timeline(count=50)
    for status in timeline:
        print status.user.name + ":" + status.text
Example #5
0
# Copyright 2009-2010 Joshua Roesslein
# See LICENSE for details.
"""
weibo API library
"""
__version__ = '1.5'
__author__ = 'Joshua Roesslein'
__license__ = 'MIT'

from weibo.weibopy.models import Status, User, DirectMessage, Friendship, SavedSearch, SearchResult, ModelFactory, IDSModel
from weibo.weibopy.error import WeibopError
from weibo.weibopy.api import API
from weibo.weibopy.cache import Cache, MemoryCache, FileCache
from weibo.weibopy.auth import BasicAuthHandler, OAuthHandler
from weibo.weibopy.streaming import Stream, StreamListener
from weibo.weibopy.cursor import Cursor

# Global, unauthenticated instance of API
api = API()


def debug(enable=True, level=1):

    import httplib
    httplib.HTTPConnection.debuglevel = level
Example #6
0
"""
Created on 2011-3-22

@author: LiuTao
"""
from weibo.weibopy import auth
from weibo.weibopy.api import API
from util import sqlite_db

if __name__ == "__main__":

    wei_bo = sqlite_db.WeiBo({"path": "db", "autocommit": True})
    #    wei_bo.create_db()

    #    wei_bo.setConsumerToken({'app_key':'168563670', 'app_secret':'f974cc11afd8cde62ff845d0860ceda2'})
    #    wei_bo.setAccessToken({'uid':1, 'access_key':"2756ed2fea9e36f46fba2dd748f13872", 'access_secret':'0b142a1e8538729158a7f01f0aebeab4'})

    app_token = wei_bo.getConsumerToken()
    access_token = wei_bo.getAccessToken(1)

    oauth_handler = auth.OAuthHandler(app_token[0][0], app_token[0][1])
    oauth_handler.set_access_token(access_token[0][0], access_token[0][1])
    client = API(oauth_handler)

    timeline = client.friends_timeline(count=50)
    for status in timeline:
        print status.user.name + ":" + status.text
Example #7
0
 def __init__(self, api=None):
     self.api = api or API()