Example #1
0
def get_hashtags():
    auth = session.get('auth')
    api = tweepy.API(auth)

    query = request.args.get('q')
    latlng = request.args.get('location')

    num_results = request.args.get('num_results', TWITTER_NUM_RESULTS)

        
    results = []
    if (query):
        for i in xrange(1, TWITTER_PAGES_TO_POLL + 1):
            results += api.search(
                query,
                lang="en",
                result_type='mixed',
                rpp=num_results,
                page=i,
            )
    else:           #tweepy doesn't allow you to search without a query...but twitter does
        for i in xrange(1, TWITTER_PAGES_TO_POLL + 1):
            results += call_api('http://search.twitter.com/search.json?',
                params = { 'geocode' : '37.781157,-122.398720,1mi', 'rpp':num_results, 'page':i } 
                )['results']

    hashtags = get_hashtags_from_search(results)
    return Response(
        response=hashtags,
        status=200,
        mimetype='application/json',
    )
Example #2
0
def get_hashtags():
    auth = session.get('auth')
    api = tweepy.API(auth)

    query = request.args.get('q')
    latlng = request.args.get('location')

    num_results = request.args.get('num_results', TWITTER_NUM_RESULTS)

    results = []
    if (query):
        for i in xrange(1, TWITTER_PAGES_TO_POLL + 1):
            results += api.search(
                query,
                lang="en",
                result_type='mixed',
                rpp=num_results,
                page=i,
            )
    else:  #tweepy doesn't allow you to search without a query...but twitter does
        for i in xrange(1, TWITTER_PAGES_TO_POLL + 1):
            results += call_api('http://search.twitter.com/search.json?',
                                params={
                                    'geocode': latlng + ',1mi',
                                    'rpp': num_results,
                                    'page': i
                                })['results']

    hashtags = get_hashtags_from_search(results)
    return Response(
        response=hashtags,
        status=200,
        mimetype='application/json',
    )
Example #3
0
def get_short_url():
    long_url = ''
    if 'url' in request.args:
        long_url = request.args['url']
    else:
        return 'error: must supply url to shorten'

    params = {
        'longUrl': long_url,
        'login': BITLY_USER,
        'apiKey': BITLY_KEY,
        'domain':'bit.ly'
    }
    return call_api(BITLY_URL, params)['data']['url']
Example #4
0
def get_short_url():
    long_url = ''
    if 'url' in request.args:
        long_url = request.args['url']
    else:
        return 'error: must supply url to shorten'

    params = {
        'longUrl': long_url,
        'login': BITLY_USER,
        'apiKey': BITLY_KEY,
        'domain': 'bit.ly'
    }
    return call_api(BITLY_URL, params)['data']['url']