当前位置: 首页>>代码示例>>Python>>正文


Python API.update_status方法代码示例

本文整理汇总了Python中weibopy.api.API.update_status方法的典型用法代码示例。如果您正苦于以下问题:Python API.update_status方法的具体用法?Python API.update_status怎么用?Python API.update_status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在weibopy.api.API的用法示例。


在下文中一共展示了API.update_status方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

# 需要导入模块: from weibopy.api import API [as 别名]
# 或者: from weibopy.api.API import update_status [as 别名]
 def get(self):
     status_id = LastID.get_by_key_name(s_name)
     if not status_id:
         return
     tl_file = urllib.urlopen(t_timeline_url % t_name)
     timeline = json.load(tl_file)
     if isinstance(timeline,list):
         last_id = int(status_id.twitter_last_id)
         tweets_to_be_post = []
         for tl in reversed(timeline):
             if int(tl['id_str']) > last_id:
                 tweets_to_be_post.append({'id_str':tl['id_str'],'text':tl['text']})
         if len(tweets_to_be_post) > 0:
             auth = BasicAuthHandler(s_name,s_pass)
             api = API(auth,source=s_app)
             for tweet_obj in tweets_to_be_post:
                 cur_id = tweet_obj['id_str']
                 cur_tweet = tweet_obj['text']
                 if cur_tweet.find('#nosina') != -1 or cur_tweet.startswith('@'):
                     continue
                 tweet = replace_tweet(cur_tweet)
                 try:
                     api.update_status(tweet)
                     status_id.twitter_last_id = cur_id
                     status_id.put()
                 except WeibopError,e:
                     self.response.out.write(e)
                     self.response.out.write('<br>')
开发者ID:PinkyJie,项目名称:Tui2Lang,代码行数:30,代码来源:twina.py

示例2: post

# 需要导入模块: from weibopy.api import API [as 别名]
# 或者: from weibopy.api.API import update_status [as 别名]
 def post(self, site):
     if site == "wb":
         content = self.get_argument("content")
         access_token = self.session.get("oauth_access_token")
         auth = OAuthHandler(options.SINA_APP_KEY, options.SINA_APP_SECRET)
         auth.set_access_token(access_token.key, access_token.secret)
         api = API(auth)
         api.update_status(content)
         self.finish(json.dumps("success"))
开发者ID:dongyi,项目名称:photo-equipment,代码行数:11,代码来源:share_handler.py

示例3: newmessage

# 需要导入模块: from weibopy.api import API [as 别名]
# 或者: from weibopy.api.API import update_status [as 别名]
 def newmessage(self, message, lat=None, long=None):
     log.debug('new message: %s' % message)
     auth = OAuthHandler(APP_KEY, APP_SECRET)
     info = user.get_app('sina', self.email)
     auth.setToken(info['access_token'], info['access_secret'])
     api = API(auth)
     api.update_status(message)
     log.debug('new message done.')
     return True
开发者ID:vincentwyshan,项目名称:VGA,代码行数:11,代码来源:sina.py

示例4: press_sina_weibo

# 需要导入模块: from weibopy.api import API [as 别名]
# 或者: from weibopy.api.API import update_status [as 别名]
def press_sina_weibo():  
    ''''' 
    调用新浪微博Open Api实现通过命令行写博文,功能有待完善 
    author: socrates 
    date:2012-02-06 
    新浪微博:@偶是正太 
    '''  
    sina_weibo_config = configparser.ConfigParser()  
    #读取appkey相关配置文件  
    try:  
        sina_weibo_config.readfp(open('sina_weibo_config.ini'))  
    except configparser.Error:  
        print ('read sina_weibo_config.ini failed.')  
      
    #获取需要的信息  
    consumer_key = sina_weibo_config.get("userinfo","CONSUMER_KEY")  
    consumer_secret =sina_weibo_config.get("userinfo","CONSUMER_SECRET")  
    token = sina_weibo_config.get("userinfo","TOKEN")  
    token_sercet = sina_weibo_config.get("userinfo","TOKEN_SECRET")  
  
    #调用新浪微博OpenApi(python版)  
    auth = OAuthHandler(consumer_key, consumer_secret)  
    auth.setAccessToken(token, token_sercet)  
    api = API(auth)  
  
    #通过命令行输入要发布的内容  
    weibo_content = input('Please input content:')  
    status = api.update_status(status=weibo_content)  
    print ("Press sina weibo successful, content is: %s" % status.text) 
开发者ID:misaka20001,项目名称:mywork,代码行数:31,代码来源:sina_test.py

示例5: on_post_was_submit

# 需要导入模块: from weibopy.api import API [as 别名]
# 或者: from weibopy.api.API import update_status [as 别名]
def on_post_was_submit(sender,post,*args,**kwargs):
    try:
        from blog.models import OptionSet
        bind = OptionSet.get('bind_weibo','')=='True'
        if bind:
            access_token_key = OptionSet.get('weibo_access_token_key','')
            access_token_secret = OptionSet.get('weibo_access_token_secret','')
            weibo_client.setToken(access_token_key,access_token_secret)
            from weibopy.api import API
            from django.template.defaultfilters import removetags
            api = API(weibo_client)
            api.update_status(status='[%s] %s ... %s'\
                              %(post.title,removetags(post.content[:60],'a p span div img br'),\
                                settings.BLOG_DOMAIN+post.get_absolute_url()))
    except:
        pass
开发者ID:Magnil,项目名称:logpress,代码行数:18,代码来源:signals.py

示例6: post_to_wb

# 需要导入模块: from weibopy.api import API [as 别名]
# 或者: from weibopy.api.API import update_status [as 别名]
def post_to_wb(request):
    if request.method == 'POST':
        success = ""
        access_token = request.session['oauth_access_token']
        auth = OAuthHandler(SINA_APP_KEY, SINA_APP_SECRET)
        auth.set_access_token(access_token.key, access_token.secret)
        api = API(auth)
        try:
            content = request.POST.get("content")
            api.update_status(content)
            success = "成功发布"
        except:
            raise
            success = "失败"
        return HttpResponseRedirect('/status')
    return HttpResponseRedirect('/status')
开发者ID:1060460048,项目名称:tornado-chatroom,代码行数:18,代码来源:wbview.py

示例7: test_rp

# 需要导入模块: from weibopy.api import API [as 别名]
# 或者: from weibopy.api.API import update_status [as 别名]
def test_rp(request):
    if request.method == 'POST':
        success = ""
        access_token = request.session['oauth_access_token']
        auth = OAuthHandler(SINA_APP_KEY, SINA_APP_SECRET)
        auth.set_access_token(access_token.key, access_token.secret)
        api = API(auth)
        try:
            username = api.me().screen_name
            number = int(md5.md5(username.encode('utf-8')).hexdigest(), 16)
            rp = number % 100
            rating = rp2rating(rp)
            api.update_status(u"%s, 你的人品是 %d, %s" %(username, rp, rating))
            success = u"成功发布"
        except:
            raise
            success = u"失败"
        return HttpResponseRedirect('/status')
    return HttpResponseRedirect('/status')
开发者ID:1060460048,项目名称:tornado-chatroom,代码行数:21,代码来源:wbview.py

示例8: __init__

# 需要导入模块: from weibopy.api import API [as 别名]
# 或者: from weibopy.api.API import update_status [as 别名]
class Weibo:
    def __init__(self):
        # 设定网页应用回调页面(桌面应用设定此变量为空)
        BACK_URL = ""
        # 验证开发者密钥.
        auth = OAuthHandler(APP_KEY, APP_SECRET, BACK_URL)
        # 设定用户令牌密钥.
        auth.setToken(TOKEN_KEY, TOKEN_SECRET)
        # 绑定用户验证信息.
        self.api = API(auth)

    def send(self, message, image_path=None):
        try:
            if image_path:
                self.api.upload(image_path, message)
            else:
                self.api.update_status(message)
        except WeibopError, e:
            print e.reason
开发者ID:kwdhd,项目名称:zhan2weibo,代码行数:21,代码来源:weibo.py

示例9: post

# 需要导入模块: from weibopy.api import API [as 别名]
# 或者: from weibopy.api.API import update_status [as 别名]
    def post(self):
        t_name = self.request.get('t_name')
        s_name = self.request.get('s_name')
        s_request_key = self.request.get('s_request_key')
        s_request_secret = self.request.get('s_request_secret')
        t_request_key = self.request.get('t_request_key')
        t_request_secret = self.request.get('t_request_secret')
        t_pin = self.request.get('t_pin')
        s_pin = self.request.get('s_pin')
        self.response.out.write("""<html><head><title>Tui2Lang-Result</title></head><body><center>""")
        if t_name == "" or s_name =="" or s_pin == "":
            self.response.out.write("""<h2>4 Input can not be empty! <a href="/">Back</a></h2>""")
        else:
            sina = OAuthHandler(app_key,app_secret)
            sina.set_request_token(s_request_key,s_request_secret)
            s_access_token = sina.get_access_token(s_pin.strip())
            sina_api = API(sina)

            twitter = tweepy.OAuthHandler(consumer_key,consumer_secret)
            twitter.set_request_token(t_request_key,t_request_secret)
            t_access_token = twitter.get_access_token(t_pin.strip())
            twitter_api = tweepy.API(twitter);
            
            t_tl = twitter_api.user_timeline()
            t_last_id = t_tl[0].id_str
            t_last_text = replace_tweet(t_tl[0].text)
            

            oauth_user = OauthUser(key_name=s_name)
            oauth_user.twitter_name = t_name
            oauth_user.sina_name = s_name
            oauth_user.sina_access_key = s_access_token.key
            oauth_user.sina_access_secret = s_access_token.secret
            oauth_user.twitter_access_key = t_access_token.key
            oauth_user.twitter_access_secret = t_access_token.secret
            oauth_user.twitter_last_id = t_last_id
            oauth_user.put()

            try:
                sina_api.update_status(t_last_text)            
            except WeibopError,e:
                self.response.out.write(e)
            else:
开发者ID:kwdhd,项目名称:Twitter2Sina,代码行数:45,代码来源:twitter2sina.py

示例10: updateWeiboStatus

# 需要导入模块: from weibopy.api import API [as 别名]
# 或者: from weibopy.api.API import update_status [as 别名]
def updateWeiboStatus(message):
    auth = OAuthHandler(CONSUMER_KEY,CONSUMER_SECRET)
    auth.setToken(ACCESS_TOKEN_KEY,ACCESS_TOKEN_SECRET)
    api=API(auth)

    message = message.encode("utf-8")
    status = api.update_status(status=message)
    
    from time import sleep
    sleep(5)
开发者ID:xipingwang,项目名称:twittersync,代码行数:12,代码来源:twittersync.py

示例11: update_weibo

# 需要导入模块: from weibopy.api import API [as 别名]
# 或者: from weibopy.api.API import update_status [as 别名]
	def update_weibo(self,message):
		self.load_setting()
		self.auth.set_request_token(self.setting['request_token'],self.setting['request_token_secret'])
		self.auth.set_access_token(self.setting['access_token'],self.setting['access_token_secret'])

		api = API(self.auth)

		is_updated = api.update_status(message)

		if(is_updated):
			print '你又在微博上跟大家说了一句话~~'
开发者ID:leecade,项目名称:AlfredWeibo,代码行数:13,代码来源:setup.py

示例12: get

# 需要导入模块: from weibopy.api import API [as 别名]
# 或者: from weibopy.api.API import update_status [as 别名]
    def get(self):
        query = db.GqlQuery("SELECT * FROM OauthUser")
        if query.count() > 0:
            for result in query:
                # rebuild twitter api
                twitter = tweepy.OAuthHandler(consumer_key,consumer_secret)
                twitter.set_access_token(result.twitter_access_key,result.twitter_access_secret)
                twitter_api = tweepy.API(twitter)
                
                timeline = twitter_api.user_timeline()
                last_id = result.twitter_last_id
                tweets_to_be_post = []
                for tl in timeline:
		    # disable jiepang
                    if int(tl.id_str) > int(last_id):
			if tl.source.find(unicode('街旁(JiePang)','utf8')) == -1  and tl.source.find('Instagram') == -1:
			    tweets_to_be_post.append({'id_str':tl.id_str,'text':tl.text})
                    else:
                        break
                if len(tweets_to_be_post) > 0:
                    # rebuild sina api
                    sina = OAuthHandler(app_key,app_secret)
                    sina.set_access_token(result.sina_access_key,result.sina_access_secret)
                    sina_api = API(sina)
                    
                    for tweet_obj in reversed(tweets_to_be_post):
                        user = OauthUser.get_by_key_name(result.sina_name)
                        cur_id = tweet_obj['id_str']
                        cur_tweet = tweet_obj['text']
                        if cur_tweet.find('#nosina') != -1 or cur_tweet.startswith('@'):
                            continue
                        tweet = replace_tweet(cur_tweet)
			self.response.out.write(tweet)
                        try:
                            sina_api.update_status(tweet)
                            user.twitter_last_id = cur_id
                            user.put()
                            self.response.out.write('同步成功!')
                        except WeibopError,e:
                            self.response.out.write(e)
                            self.response.out.write('<br>')
开发者ID:kwdhd,项目名称:Twitter2Sina,代码行数:43,代码来源:twitter2sina.py

示例13: __init__

# 需要导入模块: from weibopy.api import API [as 别名]
# 或者: from weibopy.api.API import update_status [as 别名]
class SinaClient:
    def __init__(self, key, secret):
        self.auth=OAuthHandler(key,secret)

    def get_auth_url(self):
        return self.auth.get_authorization_url()

    def set_access_token(self,token):
        key,secret=token.split('|')
        self.auth.setToken(key,secret)
        self.api=API(self.auth)

    def get_access_token(self):
        token=self.auth.access_token
        return token.key+'|'+token.secret

    def set_request_token(self,token):
        key,secret=token.split('|')
        self.auth.request_token=oauth.OAuthToken(key,secret)

    def get_request_token(self):
        token=self.auth.request_token
        return token.key+'|'+token.secret

    def set_verifier(self,verifier):
        self.auth.get_access_token(verifier)
        self.api=API(self.auth)

    def send_msg(self,msg,coord=None):
        lat,long=self.get_lat_long(coord)
        msg=msg.encode('utf-8')
        status=self.api.update_status(status=msg,lat=lat,long=long)
        return status

    def send_pic(self,msg,pic,coord=None):
        lat,long=self.get_lat_long(coord)
        msg=msg.encode('utf-8')
        status=self.api.upload(pic,status=msg,lat=lat,long=long)
        
        return status

    def get_timeline(self):
        return self.request(SINA_USER_TIMELINE_URL)

    def get_lat_long(self,coord):
        if not coord:
          return (None,None)

        return map(lambda x:str(x),coord)

    def get_user(self):
        return self.api.verify_credentials()
开发者ID:renorzr,项目名称:twsync,代码行数:54,代码来源:sinaclient.py

示例14: __init__

# 需要导入模块: from weibopy.api import API [as 别名]
# 或者: from weibopy.api.API import update_status [as 别名]
class Bot:
    def __init__(self):
        BACK_URL = ""
        #验证开发者密钥.
        auth = OAuthHandler( APP_KEY, APP_SECRET, BACK_URL )
        auth.setToken( BOT_TOKEN_KEY, BOT_TOKEN_SECRET )
        self.api = API(auth)

    def send(self, message):
        try:
            return self.api.update_status(message)
        except WeibopError, e:
            return self.api.user_timeline(count=1)[0]
开发者ID:SAEPython,项目名称:Save2Weibo,代码行数:15,代码来源:bot.py

示例15: Test

# 需要导入模块: from weibopy.api import API [as 别名]
# 或者: from weibopy.api.API import update_status [as 别名]
class Test(unittest.TestCase):
    
    consumer_key=''
    consumer_secret=''
    
    def __init__(self):
            """ constructor """
    
    def getAtt(self, key):
        try:
            return self.obj.__getattribute__(key)
        except Exception as e:
            print(e)
            return ''
        
    def auth(self):
        
        if len(self.consumer_key) == 0:
            print("Please set consumer_key£¡£¡£¡")
            return
        
        if len(self.consumer_key) == 0:
            print("Please set consumer_secret£¡£¡£¡")
            return
                
        self.auth = OAuthHandler(self.consumer_key, self.consumer_secret)
        auth_url = self.auth.get_authorization_url()
        print('Please authorize: ' + auth_url)
        verifier = input('PIN: ').strip()
        self.auth.get_access_token(verifier)
        self.api = API(self.auth)
        
    def setAccessToken(self, key, secret):
        self.auth = OAuthHandler(self.consumer_key, self.consumer_secret)
        self.auth.setAccessToken(key, secret)
        self.api = API(self.auth)
    
    def update(self, message):
        status = self.api.update_status(message)
        self.obj = status
        id = self.getAtt("id")
        text = self.getAtt("text")
        print("update,id="+ str(id) +",text="+ text)
        
    def destroy_status(self, id):
        status = self.api.destroy_status(id)
        self.obj = status
        id = self.getAtt("id")
        text = self.getAtt("text")
        print("update---"+ str(id) +":"+ text)
开发者ID:chengjun,项目名称:Research,代码行数:52,代码来源:oauthUpdate.py


注:本文中的weibopy.api.API.update_status方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。