Python django.conf.settings 模块,TWITTER_ACCESS_TOKEN_SECRET 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用django.conf.settings.TWITTER_ACCESS_TOKEN_SECRET

项目:kodla-website    作者:unicrow    | 项目源码 | 文件源码
def get_tweets(request):
    datas = []
    p = ttp.Parser()

    try:
        api = twitter.Api(
            consumer_key=settings.TWITTER_CONSUMER_KEY,
            consumer_secret=settings.TWITTER_CONSUMER_SECRET,
            access_token_key=settings.TWITTER_ACCESS_TOKEN,
            access_token_secret=settings.TWITTER_ACCESS_TOKEN_SECRET
        )

        tweets = api.GetUserTimeline(screen_name='kodlaco')
        for tweet in tweets:
            datas.append({
                #'text': p.parse(tweet.text).html,
                'text': tweet.text,
                'id_str': tweet.id_str
            })
    except:
        datas = []

    return HttpResponse(json.dumps(datas), content_type="application/json")
项目:pytrade-me    作者:arshpreetsingh    | 项目源码 | 文件源码
def handle(self, *args, **options):

        api = twitter.Api(consumer_key=settings.TWITTER_CONSUMER_KEY,
                          consumer_secret=settings.TWITTER_CONSUMER_SECRET,
                          access_token_key=settings.TWITTER_ACCESS_TOKEN_KEY,
                          access_token_secret=settings.TWITTER_ACCESS_TOKEN_SECRET)

        for currency_symbol in settings.SOCIAL_NETWORK_SENTIMENT_CONFIG['twitter']:
            print(currency_symbol)
            results = api.GetSearch("$" + currency_symbol, count=200)
            for tweet in results:

                if SocialNetworkMention.objects.filter(network_name='twitter', network_id=tweet.id).count() == 0:
                    snm = SocialNetworkMention.objects.create(
                        network_name='twitter',
                        network_id=tweet.id,
                        network_username=tweet.user.screen_name,
                        network_created_on=datetime.datetime.fromtimestamp(tweet.GetCreatedAtInSeconds()),
                        text=tweet.text,
                        symbol=currency_symbol,
                    )
                    snm.set_sentiment()
                    snm.save()
项目:pytrader    作者:owocki    | 项目源码 | 文件源码
def handle(self, *args, **options):

        api = twitter.Api(consumer_key=settings.TWITTER_CONSUMER_KEY,
                          consumer_secret=settings.TWITTER_CONSUMER_SECRET,
                          access_token_key=settings.TWITTER_ACCESS_TOKEN_KEY,
                          access_token_secret=settings.TWITTER_ACCESS_TOKEN_SECRET)

        for currency_symbol in settings.SOCIAL_NETWORK_SENTIMENT_CONFIG['twitter']:
            print(currency_symbol)
            results = api.GetSearch("$" + currency_symbol, count=200)
            for tweet in results:

                if SocialNetworkMention.objects.filter(network_name='twitter', network_id=tweet.id).count() == 0:
                    snm = SocialNetworkMention.objects.create(
                        network_name='twitter',
                        network_id=tweet.id,
                        network_username=tweet.user.screen_name,
                        network_created_on=datetime.datetime.fromtimestamp(tweet.GetCreatedAtInSeconds()),
                        text=tweet.text,
                        symbol=currency_symbol,
                    )
                    snm.set_sentiment()
                    snm.save()
项目:django-knowledge-share    作者:vintasoftware    | 项目源码 | 文件源码
def post_microblog_post_on_twitter(microblog_post):
    api = Twitter(
        api_key=settings.TWITTER_API_KEY,
        api_secret=settings.TWITTER_API_SECRET,
        access_token=settings.TWITTER_ACCESS_TOKEN,
        access_token_secret=settings.TWITTER_ACCESS_TOKEN_SECRET
    )
    post_content = format_twitter_post(microblog_post)
    try:
        api.statuses_update().post(params={'status': post_content})
        microblog_post.posted_on_twitter = True
        microblog_post.save()
    except ClientError:
        logger.error(
            "Tried to post a microblog post on Twitter but got a ClientError, "
            "check your twitter keys.")
        raise
项目:Quantrade    作者:quant-trade    | 项目源码 | 文件源码
def connect():
    api = twitter.Api(consumer_key=settings.SOCIAL_AUTH_TWITTER_KEY, \
          consumer_secret=settings.SOCIAL_AUTH_TWITTER_SECRET, \
          access_token_key=settings.TWITTER_ACCESS_TOKEN_KEY, \
          access_token_secret=settings.TWITTER_ACCESS_TOKEN_SECRET)

    return api